threads / discuss / 5647

git commands that only work correctly at top directory

Subject: git commands that only work correctly at top directory

## tl;dr

12 messages between Sep 22, 2006 and Sep 28, 2006.

replies: 11people: 6as markdown or json

Nguyen Thai Ngoc Duy· Sep 22, 2006, 09:21 UTC · lore

Here is the list (checks are done in with 1.4.2.rc4): count-objects (always 0 objects, 0 kilobytes) bisect (fatal: Not a git repository: '.git'. Bad HEAD - I need a symbolic ref) describe (fatal: Not a valid object name HEAD) repack (line 42: cd: .git/objects/pack: No such file or directory. And it creates a new .git directory in current directory) git format-patch in subdir generates files in topdir instead of current dir as documented in its man page

BTW, either git blame or git annotate should be available in git help's listing. git format-patch with no argument shows nothing. It should show help usage instead. I might miss some commands because I only tested commands I'm familiar with.

-- 
Duy
Matthias Lederhofer· Sep 22, 2006, 11:12 UTC · re: Nguyen Thai Ngoc Duy · lore

[PATCH] format-patch: use cwd as default output directory

--- Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:

> git format-patch in subdir generates files in topdir instead of
> current dir as documented in its man page
Here is a patch for this.
---
 builtin-log.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/builtin-log.c b/builtin-log.c
index fbc58bb..130b53a 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -270,6 +270,8 @@ int cmd_format_patch(int argc, const cha
 
 	rev.extra_headers = extra_headers;
 
+	output_directory = prefix;
+
 	/*
 	 * Parse the arguments before setup_revisions(), or something
 	 * like "git fmt-patch -o a123 HEAD^.." may fail; a123 is
-- 
1.4.2.1.ge767
Nguyen Thai Ngoc Duy· Sep 28, 2006, 10:25 UTC · re: Matthias Lederhofer · lore

Re: [PATCH] format-patch: use cwd as default output directory

This patch works great. I assume you forgot it?
On 9/22/06, Matthias Lederhofer <matled@gmx.net> wrote:
Show 26 quoted lines
> ---
> Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
> > git format-patch in subdir generates files in topdir instead of
> > current dir as documented in its man page
> Here is a patch for this.
> ---
>  builtin-log.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/builtin-log.c b/builtin-log.c
> index fbc58bb..130b53a 100644
> --- a/builtin-log.c
> +++ b/builtin-log.c
> @@ -270,6 +270,8 @@ int cmd_format_patch(int argc, const cha
>
>         rev.extra_headers = extra_headers;
>
> +       output_directory = prefix;
> +
>         /*
>          * Parse the arguments before setup_revisions(), or something
>          * like "git fmt-patch -o a123 HEAD^.." may fail; a123 is
> --
> 1.4.2.1.ge767
>
>
-- 
Duy
Matthias Lederhofer· Sep 28, 2006, 19:55 UTC · re: Junio C Hamano · lore

[PATCH] git-format-patch: fix bug using -o in subdirectories

This was introduced by me in commit v1.4.2.1-gc08e524.
Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
Junio C Hamano <junkio@cox.net> wrote:
Show 5 quoted lines
> "Nguyen Thai Ngoc Duy" <pclouds@gmail.com> writes:
> 
> > This patch works great. I assume you forgot it?
> 
> Thanks for reminding.
Argh, there is a bug.  When prefix is not NULL and -o is specified
git-format-patch fails:
~/src/git/a% ../git-format-patch -o ./b HEAD~1
fatal: Two output directories?
---
 builtin-log.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/builtin-log.c b/builtin-log.c
index 130b53a..9d1ceae 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -270,8 +270,6 @@ int cmd_format_patch(int argc, const cha
 
 	rev.extra_headers = extra_headers;
 
-	output_directory = prefix;
-
 	/*
 	 * Parse the arguments before setup_revisions(), or something
 	 * like "git fmt-patch -o a123 HEAD^.." may fail; a123 is
@@ -350,6 +348,9 @@ int cmd_format_patch(int argc, const cha
 	if (!rev.diffopt.output_format)
 		rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH;
 
+	if (!output_directory)
+		output_directory = prefix;
+
 	if (output_directory) {
 		if (use_stdout)
 			die("standard output, or directory, which one?");
-- 
1.4.2.1.ge767
Matthias Lederhofer· Sep 22, 2006, 11:26 UTC · re: Nguyen Thai Ngoc Duy · lore

Re: git commands that only work correctly at top directory

Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
Show 7 quoted lines
> Here is the list (checks are done in with 1.4.2.rc4):
> count-objects (always 0 objects, 0 kilobytes)
> bisect (fatal: Not a git repository: '.git'. Bad HEAD - I need a symbolic 
> ref)
> describe (fatal: Not a valid object name HEAD)
> repack (line 42: cd: .git/objects/pack: No such file or directory. And
> it creates a new .git directory in current directory)

count-objects and describe work in the current master. repack/bisect/reset and some other commands make only sense from the toplevel directory but anyway I would allow them to be run in a subdirectory and change up to the topdirectory (like git checkout for branch switching). Is there any good reason not to do this? I found it often annoying to go down to the toplevel directory/get a new shell just to reset to HEAD~1.

Nguyen Thai Ngoc Duy· Sep 22, 2006, 12:57 UTC · re: Matthias Lederhofer · lore

Re: git commands that only work correctly at top directory

On 9/22/06, Matthias Lederhofer <matled@gmx.net> wrote:
> count-objects and describe work in the current master.
Yes. Somehow my master is not updated to origin :(
Show 6 quoted lines
> repack/bisect/reset and some other commands make only sense from the
> toplevel directory but anyway I would allow them to be run in a
> subdirectory and change up to the topdirectory (like git checkout for
> branch switching).  Is there any good reason not to do this?  I found
> it often annoying to go down to the toplevel directory/get a new shell
> just to reset to HEAD~1.

In case there is good reason not to do it, I'd like those commands to tell users run them in top directory. (Although I prefer to run it everywhere, I hate to cd around just for one command)

-- 
Duy
Petr Baudis· Sep 23, 2006, 15:16 UTC · re: Matthias Lederhofer · lore

Re: git commands that only work correctly at top directory

Dear diary, on Fri, Sep 22, 2006 at 01:26:15PM CEST, I got a letter where Matthias Lederhofer <matled@gmx.net> said that...

Show 6 quoted lines
> repack/bisect/reset and some other commands make only sense from the
> toplevel directory but anyway I would allow them to be run in a
> subdirectory and change up to the topdirectory (like git checkout for
> branch switching).  Is there any good reason not to do this?  I found
> it often annoying to go down to the toplevel directory/get a new shell
> just to reset to HEAD~1.

Probably not for repack, but in case of bisect and especially reset it would be reasonable to expect that it will touch just the subdirectory and in case of git reset --hard that could be deadly.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)
Jeff King· Sep 22, 2006, 15:10 UTC · re: Nguyen Thai Ngoc Duy · lore

[PATCH] git-repack: allow git-repack to run in subdirectory

Now that we explicitly create all tmpfiles below $GIT_DIR, there's no reason to care about which directory we're in.

Signed-off-by: Jeff King <peff@peff.net>
---
 git-repack.sh |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/git-repack.sh b/git-repack.sh
index 9ae5092..f2c9071 100755
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -4,6 +4,7 @@ # Copyright (c) 2005 Linus Torvalds
 #
 
 USAGE='[-a] [-d] [-f] [-l] [-n] [-q]'
+SUBDIRECTORY_OK='Yes'
 . git-sh-setup
 
 no_update_info= all_into_one= remove_redundant=
-- 
1.4.2.1.gb6052-dirty
Thomas Kolejka· Sep 22, 2006, 17:08 UTC · re: Nguyen Thai Ngoc Duy · lore

Re: git commands that only work correctly at top directory

-------- Original-Nachricht --------
Datum: Fri, 22 Sep 2006 16:21:09 +0700
Von: "Nguyen Thai Ngoc Duy" <pclouds@gmail.com>
An: git@vger.kernel.org
Betreff: git commands that only work correctly at top directory
Did you set $GIT_DIR? ... to an absolute path or "./.git" ?
> Here is the list (checks are done in with 1.4.2.rc4):
> count-objects (always 0 objects, 0 kilobytes)
Works for me in every directory with GIT_DIR abolute or ./.git
> bisect (fatal: Not a git repository: '.git'. Bad HEAD - I need a symbolic
> ref)
with an absolute GIT_DIR works from every directory - at least bisect start
> describe (fatal: Not a valid object name HEAD)

with an absolute GIT_DIR works from every directory. v1.4.1-gcddb939

Show 13 quoted lines
> repack (line 42: cd: .git/objects/pack: No such file or directory. And
> it creates a new .git directory in current directory)
> git format-patch in subdir generates files in topdir instead of
> current dir as documented in its man page
> 
> BTW, either git blame or git annotate should be available in git help's
> listing.
> git format-patch with no argument shows nothing. It should show help
> usage instead.
> I might miss some commands because I only tested commands I'm familiar
> with.
> -- 
> Duy
Thomas
-- 
NEU: GMX DSL Sofort-Start-Set - blitzschnell ins Internet!
Echte DSL-Flatrate ab 0,- Euro* http://www.gmx.net/de/go/dsl
Jeff King· Sep 25, 2006, 02:31 UTC · re: Nguyen Thai Ngoc Duy · lore

[PATCH/RESEND] git-repack: allow git-repack to run in subdirectory

Now that we explicitly create all tmpfiles below $GIT_DIR, there's no reason to care about which directory we're in.

Signed-off-by: Jeff King <peff@peff.net>
---
There was no response on this; is there any reason not to allow this, or
did it just get dropped?
 git-repack.sh |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/git-repack.sh b/git-repack.sh
index 9ae5092..f2c9071 100755
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -4,6 +4,7 @@ # Copyright (c) 2005 Linus Torvalds
 #
 
 USAGE='[-a] [-d] [-f] [-l] [-n] [-q]'
+SUBDIRECTORY_OK='Yes'
 . git-sh-setup
 
 no_update_info= all_into_one= remove_redundant=
-- 
1.4.2.1.gb6052-dirty
Junio C Hamano· Sep 25, 2006, 03:16 UTC · re: Jeff King · lore

Re: [PATCH/RESEND] git-repack: allow git-repack to run in subdirectory

Jeff King <peff@peff.net> writes:
Show 7 quoted lines
> Now that we explicitly create all tmpfiles below $GIT_DIR, there's no reason
> to care about which directory we're in.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> There was no response on this; is there any reason not to allow this, or
> did it just get dropped?
Simply forgotten; it might be _correct_ but it is not important.

While it may technically be correct that the command could be run from anywhere, repack is a whole repository operation, and it is an operation performed not that often. There is no reason to forbid it to run from subdirectories, but it does not hurt users much if it did.

Will queue for "next" and push it out before 1.4.3 if I do not forget it again ;-).

← back to recent threads