Created
August 4, 2008 17:47
-
-
Save pieter/3936 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 4c168e77f207bd393c984647dd8fe4563ea711e3 Mon Sep 17 00:00:00 2001 | |
From: Pieter de Bie <pdebie@ai.rug.nl> | |
Date: Mon, 4 Aug 2008 19:21:18 +0200 | |
Subject: [PATCH] builtin-bundle: add a --basis option that specifies a basis | |
While basis can already be specified using the ^ref syntax, a separate | |
parameter is more userfriendly. | |
Signed-off-by: Pieter de Bie <pdebie@ai.rug.nl> | |
--- | |
Documentation/git-bundle.txt | 11 ++++++++--- | |
builtin-bundle.c | 13 +++++++++++-- | |
2 files changed, 19 insertions(+), 5 deletions(-) | |
diff --git a/Documentation/git-bundle.txt b/Documentation/git-bundle.txt | |
index 1b66ab7..91d5a4f 100644 | |
--- a/Documentation/git-bundle.txt | |
+++ b/Documentation/git-bundle.txt | |
@@ -9,7 +9,7 @@ git-bundle - Move objects and refs by archive | |
SYNOPSIS | |
-------- | |
[verse] | |
-'git bundle' create <file> <git-rev-list args> | |
+'git bundle' create <file> [--basis=ref] <git-rev-list args> | |
'git bundle' verify <file> | |
'git bundle' list-heads <file> [refname...] | |
'git bundle' unbundle <file> [refname...] | |
@@ -74,6 +74,11 @@ unbundle <file>:: | |
necessarily everything in the pack (in this case, 'git-bundle' is | |
acting like 'git-fetch-pack'). | |
+--basis:: | |
+ Specify a basis ref that already exists on the remote side. This | |
+ allows git-bundle to only write out objects that are newer, thus | |
+ saving space. | |
+ | |
SPECIFYING REFERENCES | |
--------------------- | |
@@ -115,14 +120,14 @@ We set a tag in R1 (lastR2bundle) after the previous such transport, | |
and move it afterwards to help build the bundle. | |
------------ | |
-$ git bundle create mybundle master ^lastR2bundle | |
+$ git bundle create mybundle --basis=lastR2bundle master | |
$ git tag -f lastR2bundle master | |
------------ | |
- Using a tag present in both repositories | |
------------ | |
-$ git bundle create mybundle master ^v1.0.0 | |
+$ git bundle create mybundle --basis=v1.0.0 master | |
------------ | |
- A basis based on time. | |
diff --git a/builtin-bundle.c b/builtin-bundle.c | |
index ac476e7..db1d7ce 100644 | |
--- a/builtin-bundle.c | |
+++ b/builtin-bundle.c | |
@@ -9,12 +9,12 @@ | |
* bundle supporting git-fetch, git-pull, and git-ls-remote | |
*/ | |
-static const char *bundle_usage="git-bundle (create <bundle> <git-rev-list args> | verify <bundle> | list-heads <bundle> [refname]... | unbundle <bundle> [refname]... )"; | |
+static const char *bundle_usage="git-bundle (create <bundle> [--basis=REF] <git-rev-list args> | verify <bundle> | list-heads <bundle> [refname]... | unbundle <bundle> [refname]... )"; | |
int cmd_bundle(int argc, const char **argv, const char *prefix) | |
{ | |
struct bundle_header header; | |
- int nongit; | |
+ int nongit, i; | |
const char *cmd, *bundle_file; | |
int bundle_fd = -1; | |
char buffer[PATH_MAX]; | |
@@ -50,6 +50,15 @@ int cmd_bundle(int argc, const char **argv, const char *prefix) | |
return !!list_bundle_refs(&header, argc, argv); | |
} | |
if (!strcmp(cmd, "create")) { | |
+ for (i = 1; i < argc; i++) { | |
+ if (!prefixcmp(argv[i], "--basis=")) { | |
+ char* new = xmalloc(strlen(argv[i]) - 8 + 2); | |
+ new[0] = '^'; | |
+ strcpy(new + 1, argv[i] + 8); | |
+ argv[i] = new; | |
+ } | |
+ | |
+ } | |
if (nongit) | |
die("Need a repository to create a bundle."); | |
return !!create_bundle(&header, bundle_file, argc, argv); | |
-- | |
1.6.0.rc1.259.g58707.dirty | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment