threads / discuss / 21794

git archive without path

Subject: git archive without path

## tl;dr

5 messages between Nov 30, 2009 and Dec 4, 2009.

replies: 4people: 4as markdown or json

Dmitry Potapov· Nov 30, 2009, 12:32 UTC · lore
Hi!

I have never run "git archive" inside of a subdirectory but somehow I have always assumed that it creates an archive containing all files in it regardless the current directory. In fact, the git-archive man page says so:

path
    If one or more paths are specified, include only these in the
    archive, otherwise include all files and subdirectories.

But it turned out that "git archive" works as "git archive .", i.e. adds files starting with the current directory. Is any rational for this behavior? It smells to me like a bug rather than a feature. I cannot imagine wanting to create archive containing just part of the whole repository just because he happened to be in that directory, and documentation clearly says that all files should be added unless one or more paths are specified.

Dmitry
Michael J Gruber· Nov 30, 2009, 13:05 UTC · re: Dmitry Potapov · lore

Re: git archive without path

Dmitry Potapov venit, vidit, dixit 30.11.2009 13:32:
Show 19 quoted lines
> Hi!
> 
> I have never run "git archive" inside of a subdirectory but somehow I
> have always assumed that it creates an archive containing all files in
> it regardless the current directory. In fact, the git-archive man page
> says so:
> 
> path
>     If one or more paths are specified, include only these in the
>     archive, otherwise include all files and subdirectories.
> 
> 
> But it turned out that "git archive" works as "git archive .", i.e.
> adds files starting with the current directory. Is any rational for
> this behavior? It smells to me like a bug rather than a feature. I
> cannot imagine wanting to create archive containing just part of the
> whole repository just because he happened to be in that directory,
> and documentation clearly says that all files should be added unless
> one or more paths are specified.
Depends on the definition of "all" :)

In fact: Two mighty powers are fighting right now for the primacy in the Land of the Git, and both carry the name "consistency" on their flags. One is the "order of the consistency of generations", also named "backwards compatibility", and one is the "order of the consistency of commands", also named "user experience".

Many commands have different defaults with respect to how they behave in a subdirectory (compare status to ls-files, e.g.), and the discussion about how to best change that are underway, most prominently in the case of git grep. I expect that we'll have a gradual migration path towards a "full-tree" default, but that is just my personal interpretation of the current "battle". In the short term the best that we can hope for is a consistent, convenient notation which enforcers a specific behaviour, such as "/" (non-existent) versus "." (existent).

Cheers, Michael

Dmitry Potapov· Nov 30, 2009, 15:45 UTC · re: Michael J Gruber · lore

Re: git archive without path

On Mon, Nov 30, 2009 at 4:05 PM, Michael J Gruber <git@drmicha.warpmail.net> wrote:

>
> Depends on the definition of "all" :)
I don't think it caries any restriction clause in this case....
Show 11 quoted lines
>
> In fact: Two mighty powers are fighting right now for the primacy in the
> Land of the Git, and both carry the name "consistency" on their flags.
> One is the "order of the consistency of generations", also named
> "backwards compatibility", and one is the "order of the consistency of
> commands", also named "user experience".
>
> Many commands have different defaults with respect to how they behave in
> a subdirectory (compare status to ls-files, e.g.), and the discussion
> about how to best change that are underway, most prominently in the case
> of git grep.

Well, "order of the consistency" is a noble cause, but I don't think the situations are comparable. The man page for git-grep has never claimed that git grep works on all files. Also, git grep works on the working tree by default, so defaulting to the current working directory at least makes some sense. I cannot say the same about git-archive, which only works on the repository and if I specified some revision without any path then I expect to have the whole archive not some part of it just because I happened to be in some subdirectory.

So, in the case of git-grep, we speak about changing the behavior that was well-known, often used, and documented as such. On contrast, git-archive documented as including all files if path is not specified.

Dmitry
Junio C Hamano· Nov 30, 2009, 16:35 UTC · re: Michael J Gruber · lore

Re: git archive without path

Michael J Gruber <git@drmicha.warpmail.net> writes:
Show 7 quoted lines
> Depends on the definition of "all" :)
>
> In fact: Two mighty powers are fighting right now for the primacy in the
> Land of the Git, and both carry the name "consistency" on their flags.
> One is the "order of the consistency of generations", also named
> "backwards compatibility", and one is the "order of the consistency of
> commands", also named "user experience".

You need to throw in another "work similarly to the counterpart outside git world" and you will have a better picture. This third consistency often sides with the first one.

In the case of "git archive" (and "git grep" in the other thread), it works like you run "tar" (and "grep -r", for "git grep") both because the original implementor wanted a version of "tar" ("grep") that works inside git world, and early adopters and users found the third consistency easy to work with, and that is why the third consistency grew into the first one.

René Scharfe· Dec 4, 2009, 23:11 UTC · re: Dmitry Potapov · lore

Re: git archive without path

Dmitry Potapov schrieb:
Show 8 quoted lines
> I have never run "git archive" inside of a subdirectory but somehow I
> have always assumed that it creates an archive containing all files in
> it regardless the current directory. In fact, the git-archive man page
> says so:
> 
> path
>     If one or more paths are specified, include only these in the
>     archive, otherwise include all files and subdirectories.

This sentence doesn't specify whose files and subdirectories are to be included -- those in the repository's root or those in the current directory. Let's fix that.

-- >8 --
Subject: archive: clarify description of path parameter
Mention that path parameters are based on the current working directory.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
--
 Documentation/git-archive.txt |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt
index 3d1c1e7..e579791 100644
--- a/Documentation/git-archive.txt
+++ b/Documentation/git-archive.txt
@@ -74,8 +74,9 @@ OPTIONS
 	The tree or commit to produce an archive for.
 
 path::
-	If one or more paths are specified, include only these in the
-	archive, otherwise include all files and subdirectories.
+	Without an optional path parameter, all files and subdirectories
+	of the current working directory are included in the archive.
+	If one or more paths are specified, only these are included.
 
 BACKEND EXTRA OPTIONS
 ---------------------

← back to recent threads