Re: [PATCH 2/2] git-tar-tree: Move code for git-archive --format=tar to archive-tar.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano schrieb:
> Rene Scharfe <rene.scharfe@xxxxxxxxxxxxxx> writes:
> 
>> This patch doesn't change any functionality, it only moves code around.  It
>> makes seeing the few remaining lines of git-tar-tree code easier. ;-)
>>
>> Signed-off-by: Rene Scharfe <rene.scharfe@xxxxxxxxxxxxxx>
> 
> Thanks.  And here is an obvious follow-up to it.
> 
> -- >8 --
> [PATCH] Remove upload-tar and make git-tar-tree a thin wrapper to git-archive

OK.

> diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c
> index aa370e3..5d2bec0 100644
> --- a/builtin-tar-tree.c
> +++ b/builtin-tar-tree.c
> @@ -8,94 +8,66 @@ #include "tar.h"
>  #include "builtin.h"
>  #include "pkt-line.h"
>  #include "archive.h"

At least the last two header references aren't needed any more.

> -	if (argc == 3) {
> -		int baselen = strlen(argv[2]);
> -		base = xmalloc(baselen + 2);
> -		memcpy(base, argv[2], baselen);
> -		base[baselen] = '/';
> -		base[baselen + 1] = '\0';
[...]
> +	case 3:
> +		/* base-path */ 
> +		basedir_arg = xmalloc(strlen(argv[2]) + 10);
> +		sprintf(basedir_arg, "--prefix=%s", argv[2]);
> +		nargv[nargc++] = basedir_arg;

Traditionally we always added a slash to the git-tar-tree base
parameter, forcing it to always be a base _directory_.  git-archive
in contrast to that simply adds the prefix to the paths; users have
to provide their own slash.  This is consistent with how we handle
--prefix parameters elsewhere.  It also means that the sprintf
format string here should be "--prefix=%s/" (and allocate one more
byte the line before).

> +	fprintf(stderr,
> +		"*** git-tar-tree is now deprecated.\n"
> +		"*** Running git-archive instead.\n***");
> +	for (i = 0; i < nargc; i++) {
> +		fputc(' ', stderr);
> +		sq_quote_print(stderr, nargv[i]);
> +	}
> +	fputc('\n', stderr);

Hey, scary message. ;-)  It certainly will aid the re-education of
our users, so I think it's OK.

Thanks,
René
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]