{"thread":{"id":"18334","subject":"[TopGit PATCH] tg-patch: fix invocation in sub working tree directory","startedAt":"2009-03-16T22:08:19Z","lastAt":"2009-03-17T08:33:26Z","messageCount":6,"participants":["Bert Wesarg","Junio C Hamano","Uwe Kleine-König"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"108149","messageId":"1237241299-25515-1-git-send-email-bert.wesarg@googlemail.com","threadId":"18334","inReplyTo":null,"subject":"[TopGit PATCH] tg-patch: fix invocation in sub working tree directory","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2009-03-16T22:08:19Z","receivedAt":"2009-03-16T22:08:19Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"tg patch won't work in a sub directory of the working tree, because 'git diff\n--name-only' prints the names relative to the top working tree.\n\nThis is only a quick fix which prefixes all file names with 'git rev-parse\n--show-cdup'. The right solution would be to cd into the top working tree\nsomewhere in tg.sh.\n\nSigned-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n\n---\n tg-patch.sh |    7 ++++++-\n 1 files changed, 6 insertions(+), 1 deletions(-)\n\ndiff --git a/tg-patch.sh b/tg-patch.sh\nindex d701c54..e33bab2 100644\n--- a/tg-patch.sh\n+++ b/tg-patch.sh\n@@ -50,13 +50,18 @@ cat_file \"$topic:.topmsg\"\n echo\n [ -n \"$(git grep $diff_opts '^[-]--' ${diff_committed_only:+\"$name\"} -- \".topmsg\")\" ] || echo '---'\n \n+# if we are in a sub working tree dir, we need to prefix all file names from\n+# git diff --name-only with this cdup\n+cdup=$(git rev-parse --show-cdup)\n+\n # Evil obnoxious hack to work around the lack of git diff --exclude\n git_is_stupid=\"$(mktemp -t tg-patch-changes.XXXXXX)\"\n git diff --name-only $diff_opts \"$base_rev\" ${diff_committed_only:+\"$name\"} -- |\n \tfgrep -vx \".topdeps\" |\n \tfgrep -vx \".topmsg\" >\"$git_is_stupid\" || : # fgrep likes to fail randomly?\n if [ -s \"$git_is_stupid\" ]; then\n-\tcat \"$git_is_stupid\" | xargs git diff --patch-with-stat $diff_opts \"$base_rev\" ${diff_committed_only:+\"$name\"} --\n+\tsed -e \"s#^#$cdup#\" \"$git_is_stupid\" |\n+\t\txargs git diff --patch-with-stat $diff_opts \"$base_rev\" ${diff_committed_only:+\"$name\"} --\n else\n \techo \"No changes.\"\n fi\n-- \ntg: (d145a7b..) bw/fix-tg-patch-in-sub-dir (depends on: master)\n"},{"id":"108153","messageId":"7vbps1umg9.fsf@gitster.siamese.dyndns.org","threadId":"18334","inReplyTo":"1237241299-25515-1-git-send-email-bert.wesarg@googlemail.com","subject":"Re: [TopGit PATCH] tg-patch: fix invocation in sub working tree directory","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-16T22:33:58Z","receivedAt":"2009-03-16T22:33:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bert Wesarg <bert.wesarg@googlemail.com> writes:\n\n> tg patch won't work in a sub directory of the working tree, because 'git diff\n> --name-only' prints the names relative to the top working tree.\n\n\"diff --relative --name-only\"?\n\n> This is only a quick fix which prefixes all file names with 'git rev-parse\n> --show-cdup'. The right solution would be to cd into the top working tree\n> somewhere in tg.sh.\n>\n> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n>\n> ---\n>  tg-patch.sh |    7 ++++++-\n>  1 files changed, 6 insertions(+), 1 deletions(-)\n>\n> diff --git a/tg-patch.sh b/tg-patch.sh\n> index d701c54..e33bab2 100644\n> --- a/tg-patch.sh\n> +++ b/tg-patch.sh\n> @@ -50,13 +50,18 @@ cat_file \"$topic:.topmsg\"\n>  echo\n>  [ -n \"$(git grep $diff_opts '^[-]--' ${diff_committed_only:+\"$name\"} -- \".topmsg\")\" ] || echo '---'\n>  \n> +# if we are in a sub working tree dir, we need to prefix all file names from\n> +# git diff --name-only with this cdup\n> +cdup=$(git rev-parse --show-cdup)\n> ...\n> +\tsed -e \"s#^#$cdup#\" \"$git_is_stupid\" |\n\nDo TopGit folks care about special characters in pathnames?\n"},{"id":"108160","messageId":"36ca99e90903161625x317556f4hc826aabd01494ca0@mail.gmail.com","threadId":"18334","inReplyTo":"7vbps1umg9.fsf@gitster.siamese.dyndns.org","subject":"Re: [TopGit PATCH] tg-patch: fix invocation in sub working tree directory","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2009-03-16T23:25:38Z","receivedAt":"2009-03-16T23:25:38Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Mon, Mar 16, 2009 at 23:33, Junio C Hamano <gitster@pobox.com> wrote:\n> Bert Wesarg <bert.wesarg@googlemail.com> writes:\n>\n>> tg patch won't work in a sub directory of the working tree, because 'git diff\n>> --name-only' prints the names relative to the top working tree.\n>\n> \"diff --relative --name-only\"?\nNo, unfortunately. In my bug case the changed file was in another\nsubtree, and --relative restricts the output to only files under the\ncurrent subtree.\n\n>\n>> This is only a quick fix which prefixes all file names with 'git rev-parse\n>> --show-cdup'. The right solution would be to cd into the top working tree\n>> somewhere in tg.sh.\n>>\n>> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n>>\n>> ---\n>>  tg-patch.sh |    7 ++++++-\n>>  1 files changed, 6 insertions(+), 1 deletions(-)\n>>\n>> diff --git a/tg-patch.sh b/tg-patch.sh\n>> index d701c54..e33bab2 100644\n>> --- a/tg-patch.sh\n>> +++ b/tg-patch.sh\n>> @@ -50,13 +50,18 @@ cat_file \"$topic:.topmsg\"\n>>  echo\n>>  [ -n \"$(git grep $diff_opts '^[-]--' ${diff_committed_only:+\"$name\"} -- \".topmsg\")\" ] || echo '---'\n>>\n>> +# if we are in a sub working tree dir, we need to prefix all file names from\n>> +# git diff --name-only with this cdup\n>> +cdup=$(git rev-parse --show-cdup)\n>> ...\n>> +     sed -e \"s#^#$cdup#\" \"$git_is_stupid\" |\n>\n> Do TopGit folks care about special characters in pathnames?\nDo 'git rev-parse --show-cdup' return anything other than slashes and dots?\n\nBert\n"},{"id":"108164","messageId":"7vwsapt2rw.fsf@gitster.siamese.dyndns.org","threadId":"18334","inReplyTo":"36ca99e90903161625x317556f4hc826aabd01494ca0@mail.gmail.com","subject":"Re: [TopGit PATCH] tg-patch: fix invocation in sub working tree directory","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-17T00:24:19Z","receivedAt":"2009-03-17T00:24:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bert Wesarg <bert.wesarg@googlemail.com> writes:\n\n> On Mon, Mar 16, 2009 at 23:33, Junio C Hamano <gitster@pobox.com> wrote:\n>> Bert Wesarg <bert.wesarg@googlemail.com> writes:\n>>\n>>> tg patch won't work in a sub directory of the working tree, because 'git diff\n>>> --name-only' prints the names relative to the top working tree.\n>>\n>> \"diff --relative --name-only\"?\n>\n> No, unfortunately. In my bug case the changed file was in another\n> subtree, and --relative restricts the output to only files under the\n> current subtree.\n\nAh, Ok, then insertion of cdup output does make sense (after all cdup was\ndesigned to be used that way).\n"},{"id":"108191","messageId":"20090317080211.GA21794@pengutronix.de","threadId":"18334","inReplyTo":"1237241299-25515-1-git-send-email-bert.wesarg@googlemail.com","subject":"Re: [TopGit PATCH] tg-patch: fix invocation in sub working tree directory","fromName":"Uwe Kleine-König","fromEmail":"u.kleine-koenig@pengutronix.de","sentAt":"2009-03-17T08:02:11Z","receivedAt":"2009-03-17T08:02:11Z","isPatch":true,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"On Mon, Mar 16, 2009 at 11:08:19PM +0100, Bert Wesarg wrote:\n> tg patch won't work in a sub directory of the working tree, because 'git diff\n> --name-only' prints the names relative to the top working tree.\nHhhm, that's not exactly the problem.\n\n\tgit diff --patch-with-stat 45c82b5 t/trivial/typo-kernel -- $path\n\nexpects $path to be relative to the top working tree.\n\nIMHO this is a strange behaviour of core git when comparing two trees\n(and not a tree and the wc).  Moreover as the output uses \"absolute\"\npaths:\n\n\tukleinek@cassiopeia:~/gsrc/linux-2.6/fs$ git diff --patch-with-stat 45c82b5 t/trivial/typo-kernel -- proc/nommu.c | diffstat -p0\n b/fs/proc/nommu.c |    2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\nBest regards\nUwe\n\n-- \nPengutronix e.K.                              | Uwe Kleine-König            |\nIndustrial Linux Solutions                    | http://www.pengutronix.de/  |\n"},{"id":"108196","messageId":"20090317083326.GA22384@pengutronix.de","threadId":"18334","inReplyTo":"1237241299-25515-1-git-send-email-bert.wesarg@googlemail.com","subject":"Re: [TopGit PATCH] tg-patch: fix invocation in sub working tree directory","fromName":"Uwe Kleine-König","fromEmail":"u.kleine-koenig@pengutronix.de","sentAt":"2009-03-17T08:33:26Z","receivedAt":"2009-03-17T08:33:26Z","isPatch":true,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Hello again,\n\nOn Mon, Mar 16, 2009 at 11:08:19PM +0100, Bert Wesarg wrote:\n> --- a/tg-patch.sh\n> +++ b/tg-patch.sh\n> @@ -50,13 +50,18 @@ cat_file \"$topic:.topmsg\"\n>  echo\n>  [ -n \"$(git grep $diff_opts '^[-]--' ${diff_committed_only:+\"$name\"} -- \".topmsg\")\" ] || echo '---'\n>  \n> +# if we are in a sub working tree dir, we need to prefix all file names from\n> +# git diff --name-only with this cdup\n> +cdup=$(git rev-parse --show-cdup)\n> +\n>  # Evil obnoxious hack to work around the lack of git diff --exclude\n>  git_is_stupid=\"$(mktemp -t tg-patch-changes.XXXXXX)\"\n>  git diff --name-only $diff_opts \"$base_rev\" ${diff_committed_only:+\"$name\"} -- |\n>  \tfgrep -vx \".topdeps\" |\n>  \tfgrep -vx \".topmsg\" >\"$git_is_stupid\" || : # fgrep likes to fail randomly?\n>  if [ -s \"$git_is_stupid\" ]; then\n> -\tcat \"$git_is_stupid\" | xargs git diff --patch-with-stat $diff_opts \"$base_rev\" ${diff_committed_only:+\"$name\"} --\n> +\tsed -e \"s#^#$cdup#\" \"$git_is_stupid\" |\n> +\t\txargs git diff --patch-with-stat $diff_opts \"$base_rev\" ${diff_committed_only:+\"$name\"} --\nMy not move pretty_tree from tg-export.sh to tg.sh and use that.\ni.e.\n\n\tgit diff $someopts \"$(pretty_tree \"$base_rev\")\" \"$(pretty_tree \"...\")\"\n\nthen we wouldn't need that git_is_stupid-hack and the relative path name\nthinggy wouldn hurt us.\n\nBest regards\nUwe\n\n-- \nPengutronix e.K.                              | Uwe Kleine-König            |\nIndustrial Linux Solutions                    | http://www.pengutronix.de/  |\n"}]}