Skip to contentSkip to conversation

Make git-tar-tree more flexible

PATCH In review Anand Kumria 4 participants 5 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make git-tar-tree more flexible

If you have a project which is setup like:
project
website
and you decide you wish to generate a tar archive of _just_ the 'project' portion, git-tar-tree is not able to help. This patch adds two parameters which can assist.

The first is '--pathlimit', which forces git-tar-tree to only generate the tar archive for project; as in:

    'git tar-tree --pathlimit=project project-1.0 tag-1.0'

The above command will mean that paths in the tar archive look like:

    project-1.0/project/src/main.c

etc.

The second parameter allows you two strip the extraneous project, as in:
'git tar-tree --strippath=project --pathlimit=project project-1.0 tag-1.0 Which will result in tar archives looking like:
project-1.0/src/main.c

This patch also updates the documentation to match the new parameters and rewrites the argument processing so that arguments can be passed in any order by the user

---
 Documentation/git-tar-tree.txt |   11 ++++++
 tar-tree.c                     |   70 ++++++++++++++++++++++++++++++----------
 2 files changed, 63 insertions(+), 18 deletions(-)
Documentation/git-tar-tree.txt +10 -1
index 2139b6f..d123329 100644
@@ -8,7 +8,7 @@ git-tar-tree - Creates a tar archive of 
 
 SYNOPSIS
 --------
-'git-tar-tree' <tree-ish> [ <base> ]
+'git-tar-tree' [--strippath=<path>] [--pathlimit=<path>] <tree-ish> [ <base> ]
 
 DESCRIPTION
 -----------
@@ -23,6 +23,15 @@ commit time as recorded in the reference
 Additionally the commit ID is stored in a global extended pax header.
 It can be extracted using git-get-tar-commit-id.
 
+OPTIONS
+-------
+--strippath::
+	Remove from the created tar archive the specified string from
+	any of the generated paths
+
+--pathlimit::
+	Create the tar archive but limit the included files to be those
+	specified by the pathlimit
 
 Author
 ------
tar-tree.c +53 -17

120 lines not on this page · raw message

Signature · 1 line
1.4.1
#1 lore raw
Quoted 11 lines · Anand Kumria

If you have a project which is setup like:
project
website
and you decide you wish to generate a tar archive of _just_ the 'project' portion, git-tar-tree is not able to help. This patch adds two parameters which can assist.

The first is '--pathlimit', which forces git-tar-tree to only generate the tar archive for project; as in:

    'git tar-tree --pathlimit=project project-1.0 tag-1.0'
Quoted 8 lines

The above command will mean that paths in the tar archive look like:

    project-1.0/project/src/main.c

etc.

The second parameter allows you two strip the extraneous project, as in:
'git tar-tree --strippath=project --pathlimit=project project-1.0 tag-1.0 Which will result in tar archives looking like:
project-1.0/src/main.c

This could be made more general and more Git-ish instead, by implementing a strip common prefix option and using a double dash option to signal that the remaining arguments are the paths of interest.

The synopsis would then look like:

	git-tar-tree [--remote=<repo>] [ --strip-common-prefix ]
		<tree-ish> [ <base> ] [ -- <paths>... ]
#2 lore raw
In reply to Anand Kumria
Quoted 6 lines · Anand Kumria

If you have a project which is setup like:
project
website
and you decide you wish to generate a tar archive of _just_ the 'project' portion, git-tar-tree is not able to help. This patch adds two parameters which can assist.

No need I see.

git tar-tree tag-1.0:project project-1.0/project git tar-tree tag-1.0:project project-1.0

#3 lore raw

Hi,

Quoted 9 lines · Junio C Hamano
Quoted 6 lines · Anand Kumria

If you have a project which is setup like:
project
website
and you decide you wish to generate a tar archive of _just_ the 'project' portion, git-tar-tree is not able to help. This patch adds two parameters which can assist.

Quoted 4 lines

No need I see.

git tar-tree tag-1.0:project project-1.0/project git tar-tree tag-1.0:project project-1.0

So how about this:

-- 8< --
[PATCH] tar-tree: illustrate an obscure feature better

Since you can tar just a subdirectory of a certain revision, tell the users so, by showing an example how to do it.

---

 Documentation/git-tar-tree.txt |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
Documentation/git-tar-tree.txt +5 -0
index 7a99acf..1e1c7fa 100644
@@ -71,6 +71,11 @@ git tar-tree --remote=example.com:git.gi
 
 	Get a tarball v1.4.0 from example.com.
 
+git tar-tree HEAD:Documentation/ git-docs > git-1.4.0-docs.tar::
+
+	Put everything in the current head's Documentation/ directory
+	into 'git-1.4.0-docs.tar', with the prefix 'git-docs/'.
+
 Author
 ------
 Written by Rene Scharfe.
#4 lore raw
Quoted 7 lines · Johannes Schindelin

So how about this:

-- 8< --
[PATCH] tar-tree: illustrate an obscure feature better

Since you can tar just a subdirectory of a certain revision, tell the users so, by showing an example how to do it.

Sounds sensible. Thanks.