{"thread":{"id":"5363","subject":"\"cg-commit -M msg-file ...\" fails when not run from top of tree","startedAt":"2006-08-23T10:27:38Z","lastAt":"2006-09-16T15:07:06Z","messageCount":3,"participants":["Jim Meyering","Jonas Fonseca"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"25797","messageId":"87d5aru4px.fsf@rho.meyering.net","threadId":"5363","inReplyTo":null,"subject":"\"cg-commit -M msg-file ...\" fails when not run from top of tree","fromName":"Jim Meyering","fromEmail":"jim@meyering.net","sentAt":"2006-08-23T10:27:38Z","receivedAt":"2006-08-23T10:27:38Z","isPatch":false,"sender":{"key":"jim@meyering.net","avatar":"https://avatars.githubusercontent.com/u/710630?v=4"},"body":"Hello,\n\nI discovered that \"cg-commit -M MSG-FILE ...\" fails when run from\na subdirectory, and when MSG-FILE is a relative file name.\nThis is using cogito-0.17.3-2 from Debian/unstable, but the problem\nremains when using the latest cogito sources, pulled minutes ago.\n\nHere's an example:\n\n  $ mkdir a; touch a/x; cg-init -m. .; cd a; echo . > x; cg-commit -M x x\n  defaulting to local storage area\n  Adding file a/x\n  Committing initial tree 341d89829a1bf9c0ccfbccf738815cbc862b3242\n  Committed as 6497164c6f8e86220ff26c6b89b9d0dbad5a7743\n  cat: x: No such file or directory\n  [Exit 1]\n\nThis appears to be due to the \"cd\", that can happen in cg-Xlib:\n\n  _git=\"${GIT_DIR:-.git}\"\n  if [ ! \"$_git_repo_unneeded\" ] && [ ! \"$GIT_DIR\" ] && [ ! -d \"$_git\" ]; then\n          _git_abs_path=\"$(git-rev-parse --git-dir 2>/dev/null)\"\n          if [ -d \"$_git_abs_path\" ]; then\n                  _git_relpath=\"$(git-rev-parse --show-prefix)\"\n==========>       cd \"$_git_abs_path/..\"         <==============\n          fi\n  fi\n  _git_objects=\"${GIT_OBJECT_DIRECTORY:-$_git/objects}\"\n\nI can work around the problem by using an absolute name for\nthe message file, but I shouldn't have to do that.\n\nFWIW, I tried setting GIT_DIR to the absolute name of the .git directory,\nbut that just made it so cg-commit failed with this diagnostic:\n\n  cg-commit: Nothing to commit\n\nJim\n"},{"id":"25870","messageId":"20060825000614.GF2817@diku.dk","threadId":"5363","inReplyTo":"87d5aru4px.fsf@rho.meyering.net","subject":"[PATCH] cg-commit: prefix the relative path to the message file","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2006-08-25T00:06:14Z","receivedAt":"2006-08-25T00:06:14Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Makes the -M switch work from a subdirectory.\n\nSigned-off-by: Jonas Fonseca <fonseca@diku.dk>\n\n---\n\nJim Meyering <jim@meyering.net> wrote Wed, Aug 23, 2006:\n> Hello,\n\nHi,\n\n> I discovered that \"cg-commit -M MSG-FILE ...\" fails when run from\n> a subdirectory, and when MSG-FILE is a relative file name.\n> This is using cogito-0.17.3-2 from Debian/unstable, but the problem\n> remains when using the latest cogito sources, pulled minutes ago.\n\nThe attached patch should fix this problem.\n\n---\n\n cg-commit |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/cg-commit b/cg-commit\nindex 0cec58f..5cebd81 100755\n--- a/cg-commit\n+++ b/cg-commit\n@@ -398,7 +398,7 @@ fi\n \n if [ \"$msgfile\" ]; then\n \t[ \"$written\" ] && echo >>\"$LOGMSG\"\n-\tcat \"$msgfile\" >>\"$LOGMSG\" || exit 1\n+\tcat \"$_git_relpath$msgfile\" >>\"$LOGMSG\" || exit 1\n \twritten=1\n fi\n \n\n-- \nJonas Fonseca\n"},{"id":"27001","messageId":"87fyerq291.fsf@rho.meyering.net","threadId":"5363","inReplyTo":"20060825000614.GF2817@diku.dk","subject":"Re: [PATCH] cg-commit: prefix the relative path to the message file","fromName":"Jim Meyering","fromEmail":"jim@meyering.net","sentAt":"2006-09-16T15:07:06Z","receivedAt":"2006-09-16T15:07:06Z","isPatch":true,"sender":{"key":"jim@meyering.net","avatar":"https://avatars.githubusercontent.com/u/710630?v=4"},"body":"Jonas Fonseca <fonseca@diku.dk> wrote:\n> Makes the -M switch work from a subdirectory.\n>\n> Signed-off-by: Jonas Fonseca <fonseca@diku.dk>\n>\n> ---\n>\n> Jim Meyering <jim@meyering.net> wrote Wed, Aug 23, 2006:\n>> Hello,\n>\n> Hi,\n>\n>> I discovered that \"cg-commit -M MSG-FILE ...\" fails when run from\n>> a subdirectory, and when MSG-FILE is a relative file name.\n>> This is using cogito-0.17.3-2 from Debian/unstable, but the problem\n>> remains when using the latest cogito sources, pulled minutes ago.\n>\n> The attached patch should fix this problem.\n>\n> ---\n>\n>  cg-commit |    2 +-\n>  1 files changed, 1 insertions(+), 1 deletions(-)\n>\n> diff --git a/cg-commit b/cg-commit\n> index 0cec58f..5cebd81 100755\n> --- a/cg-commit\n> +++ b/cg-commit\n> @@ -398,7 +398,7 @@ fi\n>\n>  if [ \"$msgfile\" ]; then\n>  \t[ \"$written\" ] && echo >>\"$LOGMSG\"\n> -\tcat \"$msgfile\" >>\"$LOGMSG\" || exit 1\n> +\tcat \"$_git_relpath$msgfile\" >>\"$LOGMSG\" || exit 1\n>  \twritten=1\n>  fi\n>\n>\n\nThank you!\nThat solved the problem for me.\n"}]}