ファイルのリストのみを取得し、\n
またはを含むファイル名または属性に回復力を持たせるために NUL 文字を使用する:
場合は、次のようにします。
属性「merge=union」を持つファイルのリスト:
git ls-files -z | git check-attr --stdin -z merge | sed -z -n -f script.sed
script.sed を使用:
# read filename
x # save filename in temporary space
n # read attribute name and discard it
n # read attribute name
s/^union$// # check if the value of the attribute match
t print # in that case goto print
b # otherwise goto the end
:print
x # restore filename from temporary space
p # print filename
# start again
インライン化された sed スクリプトと同じこと (つまり、-e
代わりに を使用-f
し、コメントを無視し、改行をセミコロンに置き換えます):
git ls-tree -z | git check-attr --stdin -z merge | sed -zne 'x;n;n;s/^union$//;t print;b;:print;x;p'
PS: 結果は NUL 文字を使用| xargs --null printf "%s\n"
してファイル名を区切ります。人間が読める方法で出力するために使用します。