2012年5月11日 星期五

使用 android property 連結 linux user space 與 android service

某些情況下我們希望在 linux user space 做某些動作或檢查,開關 android service
透過 android property 的 set property (setprop in init.rc 或 command line 或 C API),
再經由 android init.rc 的
on property:my.property=value
語法再執行 start/stop service 就可以完成這個連結



修改過檔案後直接 git pull 為何一定失敗?

原本已經習慣的 git pull 如果失敗,就 git stash 保留 working tree 再 git pull,最後 git stash pop 看 git auto merge 或有 conflict 再手動解之後 git add, git commit ...

但今天被問到為何直接修改檔案後 git pull 都會必須 stash 或 commit 時,卻答不出來

答案在 git help pull 的說明中,git pull 其實是 git fetch 再 git merge,而 merge 一定要是一個 branch,但在 working tree 內修改過的內容如果沒 commit 就不屬於這個 working tree 對應的 branch,因此 git 會警告你要先 commit (之後會 auto merge 或 conflict),或者是依我目前習慣的 git stash 暫存修改,等 git pull (主要是 merge) 之後再 git stash pop。不然可能會有遺失 work tree 修改的風險。

stash 想成是 stack 就比較容易理解,0 在最上面是 top,數字越大放在越底下表示越舊的資料,也符合一般圖解的 stack 示意圖。

習慣的動作習慣以後,本來就沒搞懂的、或遺忘細節,一被問就倒了 XD