* [PATCH] git-push: Update documentation to describe the no-refspec behavior.
From: Carl Worth @ 2006-02-22 4:28 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
[-- Attachment #1: Type: text/plain, Size: 1413 bytes --]
It turns out that the git-push documentation didn't describe what it
would do when not given a refspec, (not on the command line, nor in a
remotes file). This is fairly important for the user who is trying to
understand operations such as:
git clone git://something/some/where
# hack, hack, hack
git push origin
I tracked the mystery behavior down to git-send-pack and lifted the
relevant portion of its documentation up to git-push, (namely that all
refs existing both locally and remotely are updated).
Signed-off-by: Carl Worth <cworth@cworth.org>
---
Documentation/git-push.txt | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
a42f22171f6f3004e524b45b16a9c5cf0386ccf3
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 5b89110..6f4a48a 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -43,6 +43,12 @@ to fast forward the remote ref that matc
the optional plus `+` is used, the remote ref is updated
even if it does not result in a fast forward update.
+
+Note: If no explicit refspec is found, (that is neither
+on the command line nor in any Push line of the
+corresponding remotes file---see below), then all the
+refs that exist both on the local side and on the remote
+side are updated.
++
Some short-cut notations are also supported.
+
* `tag <tag>` means the same as `refs/tags/<tag>:refs/tags/<tag>`.
--
1.2.2.gfdc0
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply related
* Re: How to not download objects more than needed?
From: Junio C Hamano @ 2006-02-22 3:22 UTC (permalink / raw)
To: Jan Harkes; +Cc: git
In-Reply-To: <20060222031136.GN5000@delft.aura.cs.cmu.edu>
Jan Harkes <jaharkes@cs.cmu.edu> writes:
> Neat, it only fetches tags that refer to things we already have. Hadn't
> checked what the automatic tag fetcher was doing.
>
> So either introduce temporary local refs that can be removed once the
> tags have been fetched,...
I think it is enough just to disable tag following when you are
promiscuously fetching. That is, do the tag following only if
the main fetch is going to store a ref because it has tracking
branch for the remote side. Otherwise the remote tags do not
matter and if you really care about them you can ask with --tags.
^ permalink raw reply
* Re: How to not download objects more than needed?
From: Jan Harkes @ 2006-02-22 3:11 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7v3bicupgb.fsf@assigned-by-dhcp.cox.net>
On Tue, Feb 21, 2006 at 05:55:48PM -0800, Junio C Hamano wrote:
> Jan Harkes <jaharkes@cs.cmu.edu> writes:
> > On Tue, Feb 21, 2006 at 04:42:34PM -0800, Linus Torvalds wrote:
> >>
> >> git pull git://git.kernel.org/....
> >>
> >> and the automatic tag following kicks in, it will first have fetched the
> >> objects once, and then when it tries to fetch the tag objects, it will
> >> fetch the objects it already fetched _again_ (plus the tags), because it
> >> will do the same object pull, but the temporary branch (to be merged) will
> >> never have been written as a branch head.
> >
> > Isn't this easily avoided by fetching the tags first?
>
> I do not think so.
>
> Notice how the tag following code uses cat-file to determine if
> the main fetch likely has slurped the object they point at.
Neat, it only fetches tags that refer to things we already have. Hadn't
checked what the automatic tag fetcher was doing.
So either introduce temporary local refs that can be removed once the
tags have been fetched, or else fix it in fetch-pack with the following
change that might do the trick for this case as well. However that one
already got shot down because of possible consistency problems.
http://marc.theaimsgroup.com/?l=git&m=113030081014456&w=2
Jan
^ permalink raw reply
* Re: Git cannot push to repository with too many tags/heads
From: Junio C Hamano @ 2006-02-22 2:56 UTC (permalink / raw)
To: Stephen C. Tweedie; +Cc: git
In-Reply-To: <7vwtfotaq3.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
> "Stephen C. Tweedie" <sct@redhat.com> writes:
>
>> send_pack()
>> then skips all other refs by doing a
>>
>> if (!ref->peer_ref)
>> continue;
>>
>> Unfortunately, exec_rev_list() is missing this, and it tries to ask
>> git-rev-list for the commit objects of *every* ref on the remote_refs
>> list, even if they have been explicitly excluded by match_refs() and
>> have no peer_ref. So with this huge repository, I can't even push a
>> single refspec without bumping into the limit of 900 refs.
>
> IIRC, the distinction was deliberate. send_pack() excludes
> what did not match because it does not want to send them.
> rev_list() adds what we know they have to "do not bother to
> send" list to make the resulting pack smaller. The time where
> it matters most is when you are pushing a new branch head (or a
> tag).
>
> I think the exec_rev_list logic should be taught to first
> include all the positive refs (i.e. the ones we are going to
> send), and then as many the negative refs (i.e. the ones we know
> they have), from newer to older, as they fit without triggering
> "argument list too long".
That is, something like this.
-- >8 --
Do not give up running rev-list when remote has insanely large number of refs.
---
cd /opt/packrat/playpen/public/in-place/git/git.junio/
git diff
diff --git a/send-pack.c b/send-pack.c
index 990be3f..cfd0eeb 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -37,24 +37,27 @@ static void exec_pack_objects(void)
static void exec_rev_list(struct ref *refs)
{
+ struct ref *ref;
static char *args[1000];
int i = 0;
args[i++] = "rev-list"; /* 0 */
args[i++] = "--objects"; /* 1 */
- while (refs) {
- char *buf = malloc(100);
+ for (ref = refs; refs; refs = refs->next) {
+ char *buf = malloc(41);
if (i > 900)
die("git-rev-list environment overflow");
- if (!is_zero_sha1(refs->old_sha1) &&
- has_sha1_file(refs->old_sha1)) {
+ if (!is_zero_sha1(refs->new_sha1)) {
args[i++] = buf;
- snprintf(buf, 50, "^%s", sha1_to_hex(refs->old_sha1));
- buf += 50;
+ snprintf(buf, 41, "%s", sha1_to_hex(refs->new_sha1));
}
- if (!is_zero_sha1(refs->new_sha1)) {
+ }
+ for (ref = refs; i < 900 && refs; refs = refs->next) {
+ char *buf = malloc(42);
+ if (!is_zero_sha1(refs->old_sha1) &&
+ has_sha1_file(refs->old_sha1)) {
args[i++] = buf;
- snprintf(buf, 50, "%s", sha1_to_hex(refs->new_sha1));
+ snprintf(buf, 42, "^%s", sha1_to_hex(refs->old_sha1));
}
refs = refs->next;
}
Compilation finished at Tue Feb 21 18:52:49
^ permalink raw reply related
* Re: [PATCH] git-ls-files: Fix, document, and add test for --error-unmatch option.
From: Junio C Hamano @ 2006-02-22 1:59 UTC (permalink / raw)
To: Carl Worth; +Cc: git
In-Reply-To: <87vev8sajl.wl%cworth@cworth.org>
Carl Worth <cworth@cworth.org> writes:
> I'm still not sure what the easiest way is for me to provide changes
> to you. I've been doing it here on the list, like with the current
> message. But would it be easier for me to send pull requests?
You can decide what is easier for _you_ ;-).
But for me, emailed patches are easier to work on than pull
requests. I will need to read and understand most of the
changes anyway, unless the change is to an isolated corner of
the system that would affect only one class of users and
breakage will be noticed either immediately or can be left
broken if nobody uses that (e.g. things like contrib/ and some
foreign SCM interfaces). I would like others on the list to be
able to review the same changes that might hit my tree and
provide extra sets of eyeballs to spot things I might miss
myself alone.
> For example, with the git-clone failure cleanup I recently did, it
> seems the new test case I wrote didn't land in your tree.
Sorry, I think I just forgot to apply that one. I still have
the message so no need to resend. Thanks for reminding.
^ permalink raw reply
* Re: Git cannot push to repository with too many tags/heads
From: Junio C Hamano @ 2006-02-22 1:59 UTC (permalink / raw)
To: Stephen C. Tweedie; +Cc: git
In-Reply-To: <1140547568.5509.21.camel@orbit.scot.redhat.com>
"Stephen C. Tweedie" <sct@redhat.com> writes:
> send_pack()
> then skips all other refs by doing a
>
> if (!ref->peer_ref)
> continue;
>
> Unfortunately, exec_rev_list() is missing this, and it tries to ask
> git-rev-list for the commit objects of *every* ref on the remote_refs
> list, even if they have been explicitly excluded by match_refs() and
> have no peer_ref. So with this huge repository, I can't even push a
> single refspec without bumping into the limit of 900 refs.
IIRC, the distinction was deliberate. send_pack() excludes
what did not match because it does not want to send them.
rev_list() adds what we know they have to "do not bother to
send" list to make the resulting pack smaller. The time where
it matters most is when you are pushing a new branch head (or a
tag).
I think the exec_rev_list logic should be taught to first
include all the positive refs (i.e. the ones we are going to
send), and then as many the negative refs (i.e. the ones we know
they have), from newer to older, as they fit without triggering
"argument list too long".
Another, probably conceptually cleaner alternative might be to
allow rev-list to read from its stdin so that we do not have to
worry about the argument list issues.
^ permalink raw reply
* Re: How to not download objects more than needed?
From: Junio C Hamano @ 2006-02-22 1:55 UTC (permalink / raw)
To: Jan Harkes; +Cc: git
In-Reply-To: <20060222011338.GL5000@delft.aura.cs.cmu.edu>
Jan Harkes <jaharkes@cs.cmu.edu> writes:
> On Tue, Feb 21, 2006 at 04:42:34PM -0800, Linus Torvalds wrote:
>>
>> git pull git://git.kernel.org/....
>>
>> and the automatic tag following kicks in, it will first have fetched the
>> objects once, and then when it tries to fetch the tag objects, it will
>> fetch the objects it already fetched _again_ (plus the tags), because it
>> will do the same object pull, but the temporary branch (to be merged) will
>> never have been written as a branch head.
>
> Isn't this easily avoided by fetching the tags first?
I do not think so.
Notice how the tag following code uses cat-file to determine if
the main fetch likely has slurped the object they point at.
^ permalink raw reply
* [PATCH] diff-delta: produce optimal pack data
From: Nicolas Pitre @ 2006-02-22 1:45 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Indexing based on adler32 has a match precision based on the block size
(currently 16). Lowering the block size would produce smaller deltas
but the indexing memory and computing cost increases significantly.
For optimal delta result the indexing block size should be 3 with an
increment of 1 (instead of 16 and 16). With such low params the adler32
becomes a clear overhead increasing the time for git-repack by a factor
of 3. And with such small blocks the adler 32 is not very useful as the
whole of the block bits can be used directly.
This patch replaces the adler32 with an open coded index value based on
3 characters directly. This gives sufficient bits for hashing and
allows for optimal delta with reasonable CPU cycles.
The resulting packs are 6% smaller on average. The increase in CPU time
is about 25%. But this cost is now hidden by the delta reuse patch
while the saving on data transfers is always there.
Signed-off-by: Nicolas Pitre <nico@cam.org>
---
diff-delta.c | 77 +++++++++++++++++++++++-----------------------------------
1 files changed, 30 insertions(+), 47 deletions(-)
54aa50fb403981a9292453b76d894a79da9698de
diff --git a/diff-delta.c b/diff-delta.c
index 2ed5984..27f83a0 100644
--- a/diff-delta.c
+++ b/diff-delta.c
@@ -20,21 +20,11 @@
#include <stdlib.h>
#include <string.h>
-#include <zlib.h>
#include "delta.h"
-/* block size: min = 16, max = 64k, power of 2 */
-#define BLK_SIZE 16
-
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-
-#define GR_PRIME 0x9e370001
-#define HASH(v, shift) (((unsigned int)(v) * GR_PRIME) >> (shift))
-
struct index {
const unsigned char *ptr;
- unsigned int val;
struct index *next;
};
@@ -42,21 +32,21 @@ static struct index ** delta_index(const
unsigned long bufsize,
unsigned int *hash_shift)
{
- unsigned int hsize, hshift, entries, blksize, i;
+ unsigned long hsize;
+ unsigned int hshift, i;
const unsigned char *data;
struct index *entry, **hash;
void *mem;
/* determine index hash size */
- entries = (bufsize + BLK_SIZE - 1) / BLK_SIZE;
- hsize = entries / 4;
- for (i = 4; (1 << i) < hsize && i < 16; i++);
+ hsize = bufsize / 4;
+ for (i = 8; (1 << i) < hsize && i < 16; i++);
hsize = 1 << i;
- hshift = 32 - i;
+ hshift = i - 8;
*hash_shift = hshift;
/* allocate lookup index */
- mem = malloc(hsize * sizeof(*hash) + entries * sizeof(*entry));
+ mem = malloc(hsize * sizeof(*hash) + bufsize * sizeof(*entry));
if (!mem)
return NULL;
hash = mem;
@@ -64,17 +54,12 @@ static struct index ** delta_index(const
memset(hash, 0, hsize * sizeof(*hash));
/* then populate it */
- data = buf + entries * BLK_SIZE - BLK_SIZE;
- blksize = bufsize - (data - buf);
- while (data >= buf) {
- unsigned int val = adler32(0, data, blksize);
- i = HASH(val, hshift);
- entry->ptr = data;
- entry->val = val;
+ data = buf + bufsize - 2;
+ while (data > buf) {
+ entry->ptr = --data;
+ i = data[0] ^ data[1] ^ (data[2] << hshift);
entry->next = hash[i];
hash[i] = entry++;
- blksize = BLK_SIZE;
- data -= BLK_SIZE;
}
return hash;
@@ -141,29 +126,27 @@ void *diff_delta(void *from_buf, unsigne
while (data < top) {
unsigned int moff = 0, msize = 0;
- unsigned int blksize = MIN(top - data, BLK_SIZE);
- unsigned int val = adler32(0, data, blksize);
- i = HASH(val, hash_shift);
- for (entry = hash[i]; entry; entry = entry->next) {
- const unsigned char *ref = entry->ptr;
- const unsigned char *src = data;
- unsigned int ref_size = ref_top - ref;
- if (entry->val != val)
- continue;
- if (ref_size > top - src)
- ref_size = top - src;
- while (ref_size && *src++ == *ref) {
- ref++;
- ref_size--;
- }
- ref_size = ref - entry->ptr;
- if (ref_size > msize) {
- /* this is our best match so far */
- moff = entry->ptr - ref_data;
- msize = ref_size;
- if (msize >= 0x10000) {
- msize = 0x10000;
+ if (data + 2 < top) {
+ i = data[0] ^ data[1] ^ (data[2] << hash_shift);
+ for (entry = hash[i]; entry; entry = entry->next) {
+ const unsigned char *ref = entry->ptr;
+ const unsigned char *src = data;
+ unsigned int ref_size = ref_top - ref;
+ if (ref_size > top - src)
+ ref_size = top - src;
+ if (ref_size > 0x10000)
+ ref_size = 0x10000;
+ if (ref_size <= msize)
break;
+ while (ref_size && *src++ == *ref) {
+ ref++;
+ ref_size--;
+ }
+ ref_size = ref - entry->ptr;
+ if (msize < ref - entry->ptr) {
+ /* this is our best match so far */
+ msize = ref - entry->ptr;
+ moff = entry->ptr - ref_data;
}
}
}
--
1.2.2.g6643-dirty
^ permalink raw reply related
* [PATCH] diff-delta: big code simplification
From: Nicolas Pitre @ 2006-02-22 1:43 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
This is much smaller and hopefully clearer code now.
Signed-off-by: Nicolas Pitre <nico@cam.org>
---
diff-delta.c | 235 +++++++++++++++++++++-------------------------------------
1 files changed, 87 insertions(+), 148 deletions(-)
167f85034d634944e90f6bff683d74ec680bb331
diff --git a/diff-delta.c b/diff-delta.c
index ac992e2..2ed5984 100644
--- a/diff-delta.c
+++ b/diff-delta.c
@@ -19,8 +19,9 @@
*/
#include <stdlib.h>
+#include <string.h>
+#include <zlib.h>
#include "delta.h"
-#include "zlib.h"
/* block size: min = 16, max = 64k, power of 2 */
@@ -29,123 +30,54 @@
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define GR_PRIME 0x9e370001
-#define HASH(v, b) (((unsigned int)(v) * GR_PRIME) >> (32 - (b)))
-
-static unsigned int hashbits(unsigned int size)
-{
- unsigned int val = 1, bits = 0;
- while (val < size && bits < 32) {
- val <<= 1;
- bits++;
- }
- return bits ? bits: 1;
-}
-
-typedef struct s_chanode {
- struct s_chanode *next;
- int icurr;
-} chanode_t;
-
-typedef struct s_chastore {
- int isize, nsize;
- chanode_t *ancur;
-} chastore_t;
-
-static void cha_init(chastore_t *cha, int isize, int icount)
-{
- cha->isize = isize;
- cha->nsize = icount * isize;
- cha->ancur = NULL;
-}
-
-static void *cha_alloc(chastore_t *cha)
-{
- chanode_t *ancur;
- void *data;
-
- ancur = cha->ancur;
- if (!ancur || ancur->icurr == cha->nsize) {
- ancur = malloc(sizeof(chanode_t) + cha->nsize);
- if (!ancur)
- return NULL;
- ancur->icurr = 0;
- ancur->next = cha->ancur;
- cha->ancur = ancur;
- }
-
- data = (void *)ancur + sizeof(chanode_t) + ancur->icurr;
- ancur->icurr += cha->isize;
- return data;
-}
-
-static void cha_free(chastore_t *cha)
-{
- chanode_t *cur = cha->ancur;
- while (cur) {
- chanode_t *tmp = cur;
- cur = cur->next;
- free(tmp);
- }
-}
+#define HASH(v, shift) (((unsigned int)(v) * GR_PRIME) >> (shift))
-typedef struct s_bdrecord {
- struct s_bdrecord *next;
- unsigned int fp;
+struct index {
const unsigned char *ptr;
-} bdrecord_t;
-
-typedef struct s_bdfile {
- chastore_t cha;
- unsigned int fphbits;
- bdrecord_t **fphash;
-} bdfile_t;
-
-static int delta_prepare(const unsigned char *buf, int bufsize, bdfile_t *bdf)
-{
- unsigned int fphbits;
- int i, hsize;
- const unsigned char *data, *top;
- bdrecord_t *brec;
- bdrecord_t **fphash;
-
- fphbits = hashbits(bufsize / BLK_SIZE + 1);
- hsize = 1 << fphbits;
- fphash = malloc(hsize * sizeof(bdrecord_t *));
- if (!fphash)
- return -1;
- for (i = 0; i < hsize; i++)
- fphash[i] = NULL;
- cha_init(&bdf->cha, sizeof(bdrecord_t), hsize / 4 + 1);
-
- top = buf + bufsize;
- data = buf + (bufsize / BLK_SIZE) * BLK_SIZE;
- if (data == top)
+ unsigned int val;
+ struct index *next;
+};
+
+static struct index ** delta_index(const unsigned char *buf,
+ unsigned long bufsize,
+ unsigned int *hash_shift)
+{
+ unsigned int hsize, hshift, entries, blksize, i;
+ const unsigned char *data;
+ struct index *entry, **hash;
+ void *mem;
+
+ /* determine index hash size */
+ entries = (bufsize + BLK_SIZE - 1) / BLK_SIZE;
+ hsize = entries / 4;
+ for (i = 4; (1 << i) < hsize && i < 16; i++);
+ hsize = 1 << i;
+ hshift = 32 - i;
+ *hash_shift = hshift;
+
+ /* allocate lookup index */
+ mem = malloc(hsize * sizeof(*hash) + entries * sizeof(*entry));
+ if (!mem)
+ return NULL;
+ hash = mem;
+ entry = mem + hsize * sizeof(*hash);
+ memset(hash, 0, hsize * sizeof(*hash));
+
+ /* then populate it */
+ data = buf + entries * BLK_SIZE - BLK_SIZE;
+ blksize = bufsize - (data - buf);
+ while (data >= buf) {
+ unsigned int val = adler32(0, data, blksize);
+ i = HASH(val, hshift);
+ entry->ptr = data;
+ entry->val = val;
+ entry->next = hash[i];
+ hash[i] = entry++;
+ blksize = BLK_SIZE;
data -= BLK_SIZE;
+ }
- for ( ; data >= buf; data -= BLK_SIZE) {
- brec = cha_alloc(&bdf->cha);
- if (!brec) {
- cha_free(&bdf->cha);
- free(fphash);
- return -1;
- }
- brec->fp = adler32(0, data, MIN(BLK_SIZE, top - data));
- brec->ptr = data;
- i = HASH(brec->fp, fphbits);
- brec->next = fphash[i];
- fphash[i] = brec;
- }
-
- bdf->fphbits = fphbits;
- bdf->fphash = fphash;
-
- return 0;
-}
-
-static void delta_cleanup(bdfile_t *bdf)
-{
- free(bdf->fphash);
- cha_free(&bdf->cha);
+ return hash;
}
/* provide the size of the copy opcode given the block offset and size */
@@ -161,23 +93,24 @@ void *diff_delta(void *from_buf, unsigne
unsigned long *delta_size,
unsigned long max_size)
{
- unsigned int i, outpos, outsize, inscnt, csize, msize, moff;
- unsigned int fp;
- const unsigned char *ref_data, *ref_top, *data, *top, *ptr1, *ptr2;
- unsigned char *out, *orig;
- bdrecord_t *brec;
- bdfile_t bdf;
+ unsigned int i, outpos, outsize, inscnt, hash_shift;
+ const unsigned char *ref_data, *ref_top, *data, *top;
+ unsigned char *out;
+ struct index *entry, **hash;
- if (!from_size || !to_size || delta_prepare(from_buf, from_size, &bdf))
+ if (!from_size || !to_size)
+ return NULL;
+ hash = delta_index(from_buf, from_size, &hash_shift);
+ if (!hash)
return NULL;
-
+
outpos = 0;
outsize = 8192;
if (max_size && outsize >= max_size)
outsize = max_size + MAX_OP_SIZE + 1;
out = malloc(outsize);
if (!out) {
- delta_cleanup(&bdf);
+ free(hash);
return NULL;
}
@@ -205,28 +138,32 @@ void *diff_delta(void *from_buf, unsigne
}
inscnt = 0;
- moff = 0;
+
while (data < top) {
- msize = 0;
- fp = adler32(0, data, MIN(top - data, BLK_SIZE));
- i = HASH(fp, bdf.fphbits);
- for (brec = bdf.fphash[i]; brec; brec = brec->next) {
- if (brec->fp == fp) {
- csize = ref_top - brec->ptr;
- if (csize > top - data)
- csize = top - data;
- for (ptr1 = brec->ptr, ptr2 = data;
- csize && *ptr1 == *ptr2;
- csize--, ptr1++, ptr2++);
-
- csize = ptr1 - brec->ptr;
- if (csize > msize) {
- moff = brec->ptr - ref_data;
- msize = csize;
- if (msize >= 0x10000) {
- msize = 0x10000;
- break;
- }
+ unsigned int moff = 0, msize = 0;
+ unsigned int blksize = MIN(top - data, BLK_SIZE);
+ unsigned int val = adler32(0, data, blksize);
+ i = HASH(val, hash_shift);
+ for (entry = hash[i]; entry; entry = entry->next) {
+ const unsigned char *ref = entry->ptr;
+ const unsigned char *src = data;
+ unsigned int ref_size = ref_top - ref;
+ if (entry->val != val)
+ continue;
+ if (ref_size > top - src)
+ ref_size = top - src;
+ while (ref_size && *src++ == *ref) {
+ ref++;
+ ref_size--;
+ }
+ ref_size = ref - entry->ptr;
+ if (ref_size > msize) {
+ /* this is our best match so far */
+ moff = entry->ptr - ref_data;
+ msize = ref_size;
+ if (msize >= 0x10000) {
+ msize = 0x10000;
+ break;
}
}
}
@@ -241,13 +178,15 @@ void *diff_delta(void *from_buf, unsigne
inscnt = 0;
}
} else {
+ unsigned char *op;
+
if (inscnt) {
out[outpos - inscnt - 1] = inscnt;
inscnt = 0;
}
data += msize;
- orig = out + outpos++;
+ op = out + outpos++;
i = 0x80;
if (moff & 0xff) { out[outpos++] = moff; i |= 0x01; }
@@ -262,7 +201,7 @@ void *diff_delta(void *from_buf, unsigne
msize >>= 8;
if (msize & 0xff) { out[outpos++] = msize; i |= 0x20; }
- *orig = i;
+ *op = i;
}
if (outpos >= outsize - MAX_OP_SIZE) {
@@ -276,7 +215,7 @@ void *diff_delta(void *from_buf, unsigne
out = realloc(out, outsize);
if (!out) {
free(tmp);
- delta_cleanup(&bdf);
+ free(hash);
return NULL;
}
}
@@ -285,7 +224,7 @@ void *diff_delta(void *from_buf, unsigne
if (inscnt)
out[outpos - inscnt - 1] = inscnt;
- delta_cleanup(&bdf);
+ free(hash);
*delta_size = outpos;
return out;
}
--
1.2.2.g6643-dirty
^ permalink raw reply related
* [PATCH] diff-delta: fold two special tests into one plus cleanups
From: Nicolas Pitre @ 2006-02-22 1:41 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Testing for realloc and size limit can be done with only one test per
loop. Make it so and fix a theoretical off-by-one comparison error in
the process.
The output buffer memory allocation is also bounded by max_size when
specified.
Finally make some variable unsigned to allow the handling of files up to
4GB in size instead of 2GB.
Signed-off-by: Nicolas Pitre <nico@cam.org>
---
diff-delta.c | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)
95c1d1f82a8e36ab1e46b8186ecb34f441914961
diff --git a/diff-delta.c b/diff-delta.c
index c2f656a..ac992e2 100644
--- a/diff-delta.c
+++ b/diff-delta.c
@@ -148,16 +148,20 @@ static void delta_cleanup(bdfile_t *bdf)
cha_free(&bdf->cha);
}
+/* provide the size of the copy opcode given the block offset and size */
#define COPYOP_SIZE(o, s) \
(!!(o & 0xff) + !!(o & 0xff00) + !!(o & 0xff0000) + !!(o & 0xff000000) + \
!!(s & 0xff) + !!(s & 0xff00) + 1)
+/* the maximum size for any opcode */
+#define MAX_OP_SIZE COPYOP_SIZE(0xffffffff, 0xffffffff)
+
void *diff_delta(void *from_buf, unsigned long from_size,
void *to_buf, unsigned long to_size,
unsigned long *delta_size,
unsigned long max_size)
{
- int i, outpos, outsize, inscnt, csize, msize, moff;
+ unsigned int i, outpos, outsize, inscnt, csize, msize, moff;
unsigned int fp;
const unsigned char *ref_data, *ref_top, *data, *top, *ptr1, *ptr2;
unsigned char *out, *orig;
@@ -169,6 +173,8 @@ void *diff_delta(void *from_buf, unsigne
outpos = 0;
outsize = 8192;
+ if (max_size && outsize >= max_size)
+ outsize = max_size + MAX_OP_SIZE + 1;
out = malloc(outsize);
if (!out) {
delta_cleanup(&bdf);
@@ -259,17 +265,15 @@ void *diff_delta(void *from_buf, unsigne
*orig = i;
}
- if (max_size && outpos > max_size) {
- free(out);
- delta_cleanup(&bdf);
- return NULL;
- }
-
- /* next time around the largest possible output is 1 + 4 + 3 */
- if (outpos > outsize - 8) {
+ if (outpos >= outsize - MAX_OP_SIZE) {
void *tmp = out;
outsize = outsize * 3 / 2;
- out = realloc(out, outsize);
+ if (max_size && outsize >= max_size)
+ outsize = max_size + MAX_OP_SIZE + 1;
+ if (max_size && outpos > max_size)
+ out = NULL;
+ else
+ out = realloc(out, outsize);
if (!out) {
free(tmp);
delta_cleanup(&bdf);
--
1.2.2.g6643-dirty
^ permalink raw reply related
* [PATCH] relax delta selection filtering in pack-objects
From: Nicolas Pitre @ 2006-02-22 1:39 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
This change provides a 8% saving on the pack size with a 4% CPU time
increase for git-repack -a on the current git archive.
Signed-off-by: Nicolas Pitre <nico@cam.org>
---
pack-objects.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
2aed7126f9b44d9ef953e8a1cbeab34356410842
diff --git a/pack-objects.c b/pack-objects.c
index ceb107f..4f8814d 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -748,11 +748,10 @@ static int try_delta(struct unpacked *cu
}
size = cur_entry->size;
- if (size < 50)
- return -1;
oldsize = old_entry->size;
sizediff = oldsize > size ? oldsize - size : size - oldsize;
- if (sizediff > size / 8)
+
+ if (size < 50)
return -1;
if (old_entry->depth >= max_depth)
return 0;
--
1.2.2.g6643-dirty
^ permalink raw reply related
* Re: How to not download objects more than needed?
From: Jan Harkes @ 2006-02-22 1:13 UTC (permalink / raw)
To: git
In-Reply-To: <Pine.LNX.4.64.0602211635450.30245@g5.osdl.org>
On Tue, Feb 21, 2006 at 04:42:34PM -0800, Linus Torvalds wrote:
>
> git pull git://git.kernel.org/....
>
> and the automatic tag following kicks in, it will first have fetched the
> objects once, and then when it tries to fetch the tag objects, it will
> fetch the objects it already fetched _again_ (plus the tags), because it
> will do the same object pull, but the temporary branch (to be merged) will
> never have been written as a branch head.
Isn't this easily avoided by fetching the tags first?
Jan
diff --git a/git-fetch.sh b/git-fetch.sh
index b4325d9..9c6748f 100755
--- a/git-fetch.sh
+++ b/git-fetch.sh
@@ -363,8 +363,6 @@ fetch_main () {
}
-fetch_main "$reflist"
-
# automated tag following
case "$no_tags$tags" in
'')
@@ -389,6 +387,8 @@ case "$no_tags$tags" in
esac
esac
+fetch_main "$reflist"
+
# If the original head was empty (i.e. no "master" yet), or
# if we were told not to worry, we do not have to check.
case ",$update_head_ok,$orig_head," in
^ permalink raw reply related
* [PATCH] git-rebase: Clarify usage statement and copy it into the actual documentation.
From: Carl Worth @ 2006-02-22 1:10 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
[-- Attachment #1: Type: text/plain, Size: 3818 bytes --]
I found a paper thin man page for git-rebase, but was quite happy to
see something much more useful in the usage statement of the script
when I went there to find out how this thing worked. Here it is
cleaned up slightly and expanded a bit into the actual documentation.
Signed-off-by: Carl Worth <cworth@cworth.org>
---
Drat. I just realized I've been neglecting the Signed-off-by: line in
my last few patches. Junio, if you'd like me to re-send those with
that fixed, just let me know.
Documentation/git-rebase.txt | 44 ++++++++++++++++++++++++++++++++++++++++--
git-rebase.sh | 24 +++++++++++++----------
2 files changed, 56 insertions(+), 12 deletions(-)
f78b6a97afd562d2cf2d30488892ff893dd81a3b
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 16c158f..f037d12 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -7,14 +7,54 @@ git-rebase - Rebase local commits to new
SYNOPSIS
--------
-'git-rebase' <upstream> [<head>]
+'git-rebase' [--onto <newbase>] <upstream> [<branch>]
DESCRIPTION
-----------
-Rebases local commits to the new head of the upstream tree.
+git-rebase applies to <upstream> (or optionally to <newbase>) commits
+from <branch> that do not appear in <upstream>. When <branch> is not
+specified it defaults to the current branch (HEAD).
+
+When git-rebase is complete, <branch> will be updated to point to the
+newly created line of commit objects, so the previous line will not be
+accessible unless there are other references to it already.
+
+Assume the following history exists and the current branch is "topic":
+
+ A---B---C topic
+ /
+ D---E---F---G master
+
+From this point, the result of the following commands:
+
+ git-rebase master
+ git-rebase master topic
+
+would be:
+
+ A'--B'--C' topic
+ /
+ D---E---F---G master
+
+While, starting from the same point, the result of the following
+commands:
+
+ git-rebase --onto master~1 master
+ git-rebase --onto master~1 master topic
+
+would be:
+
+ A'--B'--C' topic
+ /
+ D---E---F---G master
OPTIONS
-------
+<newbase>::
+ Starting point at which to create the new commits. If the
+ --onto option is not specified, the starting point is
+ <upstream>.
+
<upstream>::
Upstream branch to compare against.
diff --git a/git-rebase.sh b/git-rebase.sh
index 21c3d83..211bf68 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -4,24 +4,28 @@
#
USAGE='[--onto <newbase>] <upstream> [<branch>]'
-LONG_USAGE='If <branch> is specified, switch to that branch first. Then,
-extract commits in the current branch that are not in <upstream>,
-and reconstruct the current on top of <upstream>, discarding the original
-development history. If --onto <newbase> is specified, the history is
-reconstructed on top of <newbase>, instead of <upstream>. For example,
-while on "topic" branch:
+LONG_USAGE='git-rebase applies to <upstream> (or optionally to <newbase>) commits
+from <branch> that do not appear in <upstream>. When <branch> is not
+specified it defaults to the current branch (HEAD).
+
+When git-rebase is complete, <branch> will be updated to point to the
+newly created line of commit objects, so the previous line will not be
+accessible unless there are other references to it already.
+
+Assuming the following history:
A---B---C topic
/
D---E---F---G master
- $ '"$0"' --onto master~1 master topic
+The result of the following command:
-would rewrite the history to look like this:
+ git-rebase --onto master~1 master topic
+ would be:
- A'\''--B'\''--C'\'' topic
- /
+ A'\''--B'\''--C'\'' topic
+ /
D---E---F---G master
'
--
1.2.2.g0a5f5-dirty
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply related
* [PATCH] cg-* manpages: Handle more than one `cg-cmd` per line
From: Jonas Fonseca @ 2006-02-22 0:48 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
... which is the case for cg-update.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
author Jonas Fonseca <fonseca@diku.dk> Wed, 22 Feb 2006 01:45:18 +0100
Documentation/make-cg-asciidoc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Documentation/make-cg-asciidoc b/Documentation/make-cg-asciidoc
index bc31809..126d4eb 100755
--- a/Documentation/make-cg-asciidoc
+++ b/Documentation/make-cg-asciidoc
@@ -42,7 +42,7 @@ CAPTION=$(echo "$HEADER" | head -n 1 | t
# were referenced as "`cg-command`". This way references from cg-* combos in
# code listings will be ignored.
BODY=$(echo "$HEADER" | sed '0,/^$/d' \
- | sed 's/`\(cg-[a-z-]\+\)`/gitlink:\1[1]/;s/^\(-.*\)::.*/\1::/')
+ | sed 's/`\(cg-[a-z-]\+\)`/gitlink:\1[1]/g;s/^\(-.*\)::.*/\1::/')
DESCRIPTION=
OPTIONS=
--
Jonas Fonseca
^ permalink raw reply related
* Re: How to not download objects more than needed?
From: Linus Torvalds @ 2006-02-22 0:42 UTC (permalink / raw)
To: sean; +Cc: Radoslaw Szkodzinski, git
In-Reply-To: <BAYC1-PASMTP03A58A4F389365AC85DA68AEFC0@CEZ.ICE>
On Tue, 21 Feb 2006, sean wrote:
>
> > I have linux-2.6 repository pulled and I'd like to download some branch
> > (say, netdev-2.6), which uses many of the same objects,
> > but not to get all the objects from the git server.
>
> Just make sure you're not using the rsync protocol. Using the
> native git protocol would be best.
Side note: the "automatic tag following" is broken wrt pulling unnecessary
objects, even with the git protocol.
What happens is that if you don't explicitly have a branch for what you
are pulling, and you do something like
git pull git://git.kernel.org/....
and the automatic tag following kicks in, it will first have fetched the
objects once, and then when it tries to fetch the tag objects, it will
fetch the objects it already fetched _again_ (plus the tags), because it
will do the same object pull, but the temporary branch (to be merged) will
never have been written as a branch head.
So you'll see something like
Generating pack...
Done counting <x> objects.
Packing <x> objects.......................
Unpacking <x> objects
100% (<x>/<x>) done
Auto-following refs/tags/v1.2.2
Generating pack...
Done counting <x+1> objects.
Packing <x+1> objects.......................
Unpacking <x+1> objects
100% (<x+1>/<x+1>) done
* refs/tags/v1.2.2: storing tag 'v1.2.2' of master.kernel.org:/pub/scm/git/git
just because we hadn't updated any refs before we started re-fetching more
objects.
So we do have cases where we fetch unnecessarily even with the native
protocol.
Linus
^ permalink raw reply
* [PATCH] git-add: Add support for --, documentation, and test.
From: Carl Worth @ 2006-02-21 23:33 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
[-- Attachment #1: Type: text/plain, Size: 1885 bytes --]
This adds support to git-add to allow the common -- to separate
command-line options and file names. It adds documentation and a new
git-add test case as well.
---
[In my tree on the git-add-dash-dash branch.]
Documentation/git-add.txt | 7 ++++++-
git-add.sh | 4 ++++
t/t3700-add.sh | 22 ++++++++++++++++++++++
3 files changed, 32 insertions(+), 1 deletions(-)
create mode 100755 t/t3700-add.sh
af9363cd7aec2b39ad7ba4594e2c4d4757e8f644
diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index 89e4614..7e29383 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -7,7 +7,7 @@ git-add - Add files to the index file.
SYNOPSIS
--------
-'git-add' [-n] [-v] <file>...
+'git-add' [-n] [-v] [--] <file>...
DESCRIPTION
-----------
@@ -26,6 +26,11 @@ OPTIONS
-v::
Be verbose.
+--::
+ This option can be used to separate command-line options from
+ the list of files, (useful when filenames might be mistaken
+ for command-line options).
+
DISCUSSION
----------
diff --git a/git-add.sh b/git-add.sh
index 13fad82..d6a4bc7 100755
--- a/git-add.sh
+++ b/git-add.sh
@@ -14,6 +14,10 @@ while : ; do
-v)
verbose=--verbose
;;
+ --)
+ shift
+ break
+ ;;
-*)
usage
;;
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
new file mode 100755
index 0000000..7c61034
--- /dev/null
+++ b/t/t3700-add.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Carl D. Worth
+#
+
+test_description='Test of git-add, including the -- option.'
+
+. ./test-lib.sh
+
+test_expect_success \
+ 'Test of git-add' \
+ 'touch foo && git-add foo'
+
+test_expect_success \
+ 'Post-check that foo is in the index' \
+ 'git-ls-files --error-unmatch foo'
+
+test_expect_success \
+ 'Test that "git-add -- -q" works' \
+ 'touch -- -q && git-add -- -q'
+
+test_done
--
1.2.2.g0a5f5-dirty
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply related
* Re: [PATCH] Add new git-rm command with documentation
From: Carl Worth @ 2006-02-21 23:04 UTC (permalink / raw)
To: Krzysiek Pawlik; +Cc: Junio C Hamano, git
In-Reply-To: <87slqcs4y5.wl%cworth@cworth.org>
[-- Attachment #1: Type: text/plain, Size: 7068 bytes --]
This adds a git-rm command which provides convenience similar to
git-add, (and a bit more since it takes care of the rm as well if
given -f).
Like git-add, git-rm expands the given path names through
git-ls-files. This means it only acts on files listed in the
index. And it does act recursively on directories by default, (no -r
needed as in the case of rm itself). When it recurses, it does not
remove empty directories that are left behind.
---
On Tue, 21 Feb 2006 14:49:22 -0800, Carl Worth wrote:
> If the -f option is desired we could get the correct behavior by using
> update-index --force-remove when not given -f and update-index
> --remove when given -f.
One good argument for having the -f behavior is that this way
"git rm file" makes a good complement for "git add file". I know that
someone (recently?) asked on the list for an "unadd" operation. This
would definitely be a lot more convenient than "git update-index
--force-remove file".
> That's enough complexity to warrant a test case. I'll be back shortly
> with that...
Here it is. This is a complete patch from master, rather than
the incremental version that's in my tree.
.gitignore | 1
Documentation/git-rm.txt | 89
+++++++++++++++++++++++++++++++++++++++++++++++
Makefile | 2 -
git-rm.sh | 67 +++++++++++++++++++++++++++++++++++
t/t3600-rm.sh | 42 ++++++++++++++++++++++
5 files changed, 200 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index d7e8d2a..94f66d5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -84,6 +84,7 @@ git-resolve
git-rev-list
git-rev-parse
git-revert
+git-rm
git-send-email
git-send-pack
git-sh-setup
diff --git a/Documentation/git-rm.txt b/Documentation/git-rm.txt
new file mode 100644
index 0000000..401bfb2
--- /dev/null
+++ b/Documentation/git-rm.txt
@@ -0,0 +1,89 @@
+git-rm(1)
+=========
+
+NAME
+----
+git-rm - Remove files from the working tree and from the index.
+
+SYNOPSIS
+--------
+'git-rm' [-f] [-n] [-v] [--] <file>...
+
+DESCRIPTION
+-----------
+A convenience wrapper for git-update-index --remove. For those coming
+from cvs, git-rm provides an operation similar to "cvs rm" or "cvs
+remove".
+
+
+OPTIONS
+-------
+<file>...::
+ Files to remove from the index and optionally, from the
+ working tree as well.
+
+-f::
+ Remove files from the working tree as well as from the index.
+
+-n::
+ Don't actually remove the file(s), just show if they exist in
+ the index.
+
+-v::
+ Be verbose.
+
+--::
+ This option can be used to separate command-line options from
+ the list of files, (useful when filenames might be mistaken
+ for command-line options).
+
+
+DISCUSSION
+----------
+
+The list of <file> given to the command is fed to `git-ls-files`
+command to list files that are registered in the index and
+are not ignored/excluded by `$GIT_DIR/info/exclude` file or
+`.gitignore` file in each directory. This means two things:
+
+. You can put the name of a directory on the command line, and the
+ command will remove all files in it and its subdirectories (the
+ directories themselves are never removed from the working tree);
+
+. Giving the name of a file that is not in the index does not
+ remove that file.
+
+
+EXAMPLES
+--------
+git-rm Documentation/\\*.txt::
+
+ Removes all `\*.txt` files from the index that are under the
+ `Documentation` directory and any of its subdirectories. The
+ files are not removed from the working tree.
++
+Note that the asterisk `\*` is quoted from the shell in this
+example; this lets the command include the files from
+subdirectories of `Documentation/` directory.
+
+git-rm -f git-*.sh::
+
+ Remove all git-*.sh scripts that are in the index. The files
+ are removed from the index, and (because of the -f option),
+ from the working tree as well. Because this example lets the
+ shell expand the asterisk (i.e. you are listing the files
+ explicitly), it does not remove `subdir/git-foo.sh`.
+
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the gitlink:git[7] suite
+
diff --git a/Makefile b/Makefile
index 317be3c..e98b056 100644
--- a/Makefile
+++ b/Makefile
@@ -109,7 +109,7 @@ SCRIPT_SH = \
git-merge-one-file.sh git-parse-remote.sh \
git-prune.sh git-pull.sh git-push.sh git-rebase.sh \
git-repack.sh git-request-pull.sh git-reset.sh \
- git-resolve.sh git-revert.sh git-sh-setup.sh \
+ git-resolve.sh git-revert.sh git-rm.sh git-sh-setup.sh \
git-tag.sh git-verify-tag.sh git-whatchanged.sh \
git-applymbox.sh git-applypatch.sh git-am.sh \
git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
diff --git a/git-rm.sh b/git-rm.sh
new file mode 100644
index 0000000..0a3f546
--- /dev/null
+++ b/git-rm.sh
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+USAGE='[-f] [-n] [-v] [--] <file>...'
+SUBDIRECTORY_OK='Yes'
+. git-sh-setup
+
+index_remove_option=--force-remove
+remove_files=
+show_only=
+verbose=
+while : ; do
+ case "$1" in
+ -f)
+ remove_files=true
+ index_remote_option=--force
+ ;;
+ -n)
+ show_only=true
+ ;;
+ -v)
+ verbose=--verbose
+ ;;
+ --)
+ shift; break
+ ;;
+ -*)
+ usage
+ ;;
+ *)
+ break
+ ;;
+ esac
+ shift
+done
+
+# This is typo-proofing. If some paths match and some do not, we want
+# to do nothing.
+case "$#" in
+0) ;;
+*)
+ git-ls-files --error-unmatch -- "$@" >/dev/null || {
+ echo >&2 "Maybe you misspelled it?"
+ exit 1
+ }
+ ;;
+esac
+
+files=$(
+ if test -f "$GIT_DIR/info/exclude" ; then
+ git-ls-files \
+ --exclude-from="$GIT_DIR/info/exclude" \
+ --exclude-per-directory=.gitignore -- "$@"
+ else
+ git-ls-files \
+ --exclude-per-directory=.gitignore -- "$@"
+ fi | sort | uniq
+)
+
+case "$show_only" in
+true)
+ echo $files
+ ;;
+*)
+ [[ "$remove_files" = "true" ]] && rm -- $files
+ git-update-index $index_remove_option $verbose $files
+ ;;
+esac
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
new file mode 100755
index 0000000..8415732
--- /dev/null
+++ b/t/t3600-rm.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Carl D. Worth
+#
+
+test_description='Test of the various options to git-rm.'
+
+. ./test-lib.sh
+
+# Setup some files to be removed
+touch foo bar
+git-add foo bar
+# Need one to test --
+touch -- -q
+git update-index --add -- -q
+git-commit -m "add foo, bar, and -q"
+
+test_expect_success \
+ 'Pre-check that foo is in index before git-rm foo' \
+ 'git-ls-files --error-unmatch foo'
+
+test_expect_success \
+ 'Test that git-rm foo succeeds' \
+ 'git-rm foo'
+
+test_expect_failure \
+ 'Post-check that foo is not in index after git-rm foo' \
+ 'git-ls-files --error-unmatch foo'
+
+test_expect_success \
+ 'Test that "git-rm -f bar" works' \
+ 'git-rm -f bar'
+
+test_expect_failure \
+ 'Post-check that bar no longer exists' \
+ '[ -f bar ]'
+
+test_expect_success \
+ 'Test that "git-rm -- -q" works to delete a file named -q' \
+ 'git-rm -- -q'
+
+test_done
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply related
* Re: [PATCH] fmt-merge-msg: avoid open "-|" list form for Perl 5.6
From: Martin Langhoff @ 2006-02-21 23:00 UTC (permalink / raw)
To: Johannes Schindelin
Cc: Alex Riesen, Sam Vilain, Junio C Hamano, Eric Wong, git
In-Reply-To: <Pine.LNX.4.63.0602212315400.12634@wbgn013.biozentrum.uni-wuerzburg.de>
On 2/22/06, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> Maybe I am stating the obvious, but it seems that
>
> open (F, "git-blabla -option |");
>
> would be more portable.
And
open (F, "git-blabla|", '-option', '$%!|');
would be portable AND safe ;-)
cheers,
martin
^ permalink raw reply
* Re: [PATCH] Add new git-rm command with documentation
From: Carl Worth @ 2006-02-21 22:49 UTC (permalink / raw)
To: Krzysiek Pawlik; +Cc: Junio C Hamano, git
In-Reply-To: <43FB8F31.9090302@people.pl>
[-- Attachment #1: Type: text/plain, Size: 487 bytes --]
On Tue, 21 Feb 2006 23:07:45 +0100, Krzysiek Pawlik wrote:
>
> I've modified it a little - it has now a '-f' option to delete files
> (much like cvs rm behaviour).
As is, without -f, git-rm will instead act just like git-update-index.
If the -f option is desired we could get the correct behavior by using
update-index --force-remove when not given -f and update-index
--remove when given -f.
That's enough complexity to warrant a test case. I'll be back shortly
with that...
-Carl
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply
* Re: What does this error message mean?
From: Timo Hirvonen @ 2006-02-21 22:46 UTC (permalink / raw)
To: git; +Cc: git
In-Reply-To: <200602212206.36685.alan@chandlerfamily.org.uk>
On Tue, 21 Feb 2006 22:06:36 +0000
Alan Chandler <alan@chandlerfamily.org.uk> wrote:
> alan@kanger usermgr[master]$ git commit -a
> fatal: empty ident <alan@chandlerfamily.org.uk> not allowed
>
> Suddenly started happening, possibly after upgrade (via debian) to git 1.2.1
Your GIT_AUTHOR_NAME is empty?
--
http://onion.dynserv.net/~timo/
^ permalink raw reply
* Re: [PATCH] fmt-merge-msg: avoid open "-|" list form for Perl 5.6
From: Sam Vilain @ 2006-02-21 22:38 UTC (permalink / raw)
To: Alex Riesen; +Cc: Junio C Hamano, Johannes Schindelin, Eric Wong, git
In-Reply-To: <20060221215742.GA5948@steel.home>
Alex Riesen wrote:
>>>Does not work here (ActiveState Build 811, Perl 5.8.6):
>>>$ perl -e 'open(F, "-|")'
>>>'-' is not recognized as an internal or external command,
>>>operable program or batch file.
>>Portability, Ease of Coding, Few CPAN Module Dependencies. Pick any two.
> Sometimes an upgrade is just out of question. Besides, that'd mean an
> upgrade to another operating system, because very important scripts
> over here a just not portable to anything else but
> "ActiveState Perl on Windows (TM)"
> I just have no choice.
Sure, but perhaps IPC::Open2 or some other CPAN module has solved this
problem already.
I guess what I'm saying is that if you want to limit the modules that
Perl script uses, you end up either impacting on the portability of the
script or rediscovering problems with early wheel designs.
Sam.
^ permalink raw reply
* Re: [PATCH] fmt-merge-msg: avoid open "-|" list form for Perl 5.6
From: Shawn Pearce @ 2006-02-21 22:38 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
In-Reply-To: <Pine.LNX.4.63.0602212315400.12634@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> Maybe I am stating the obvious, but it seems that
>
> open (F, "git-blabla -option |");
>
> would be more portable.
Yes but that gets broken up and processed according to your shell.
Which could be ugly if you try to include shell meta-characters.
On the other hand if the entire string passed to open is a constant
in the script then there's really no danger and it would be more
portable.
> P.S.: Eric, we rely on fork() anyway. Most of git's programs just don't
> work without a fork().
Which is why GIT requires Cygwin on Windows. So why not use
the Cygwin perl when using GIT? I think that uses Cygwin's fork
emulation to implement fork, rather than the ActiveState emulation
of fork.
Of course fork on Cygwin is painfully slow. :-|
--
Shawn.
^ permalink raw reply
* Re: [PATCH] Add new git-rm command with documentation
From: Krzysiek Pawlik @ 2006-02-21 22:36 UTC (permalink / raw)
To: Shawn Pearce; +Cc: cworth, git
In-Reply-To: <20060221223254.GB20744@spearce.org>
[-- Attachment #1.1: Type: text/plain, Size: 326 bytes --]
Shawn Pearce wrote:
> You are leaving -- in $@ for processing later, which means we'll
> try to delete the file '--'. :-)
>
> I think a shift before the break in the -- case would fix this.
Yay! Another stupid mistake from me ;) Thanks again :)
--
Krzysiek Pawlik (Nelchael)
RLU #322999 GPG Key ID: 0xBC555551
[-- Attachment #1.2: git-rm.patch --]
[-- Type: text/plain, Size: 4287 bytes --]
diff -Nru git-1.2.2/.gitignore git-1.2.2.patched/.gitignore
--- git-1.2.2/.gitignore 2006-02-19 01:19:00.000000000 +0100
+++ git-1.2.2.patched/.gitignore 2006-02-21 22:56:23.000000000 +0100
@@ -84,6 +84,7 @@
git-rev-list
git-rev-parse
git-revert
+git-rm
git-send-email
git-send-pack
git-sh-setup
diff -Nru git-1.2.2/Documentation/git-rm.txt git-1.2.2.patched/Documentation/git-rm.txt
--- git-1.2.2/Documentation/git-rm.txt 1970-01-01 01:00:00.000000000 +0100
+++ git-1.2.2.patched/Documentation/git-rm.txt 2006-02-21 23:00:13.000000000 +0100
@@ -0,0 +1,80 @@
+git-rm(1)
+=========
+
+NAME
+----
+git-rm - Remove files from the index.
+
+SYNOPSIS
+--------
+'git-rm' [-n|-f] [-v] <file>...
+
+DESCRIPTION
+-----------
+A convenience wrapper for rm and git-update-index --remove. For those
+coming from cvs, git-rm provides an operation similar to "cvs rm -f".
+
+
+OPTIONS
+-------
+<file>...::
+ Files to remove from the working tree and the index.
+
+-n::
+ Don't actually remove the file(s), just show if they exist in
+ the index.
+
+-f::
+ Delete the file(s) before removing it.
+
+-v::
+ Be verbose.
+
+
+DISCUSSION
+----------
+
+The list of <file> given to the command is fed to `git-ls-files`
+command to list files that are registered in the index and
+are not ignored/excluded by `$GIT_DIR/info/exclude` file or
+`.gitignore` file in each directory. This means two things:
+
+. You can put the name of a directory on the command line, and the
+ command will remove all files in it and its subdirectories (the
+ directories themselves are not removed);
+
+. Giving the name of a file that is not in the index does not
+ remove that file.
+
+
+EXAMPLES
+--------
+git-rm Documentation/\\*.txt::
+
+ Removes all `\*.txt` files that are in the index under
+ `Documentation` directory and its subdirectories.
++
+Note that the asterisk `\*` is quoted from the shell in this
+example; this lets the command include the files from
+subdirectories of `Documentation/` directory.
+
+git-rm git-*.sh::
+
+ Remove all git-*.sh scripts that are in the index.
+ Because this example lets the shell expand the asterisk
+ (i.e. you are listing the files explicitly), it does not
+ remove `subdir/git-foo.sh`.
+
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the gitlink:git[7] suite
+
diff -Nru git-1.2.2/Makefile git-1.2.2.patched/Makefile
--- git-1.2.2/Makefile 2006-02-19 01:19:00.000000000 +0100
+++ git-1.2.2.patched/Makefile 2006-02-21 22:56:23.000000000 +0100
@@ -107,7 +107,7 @@
git-merge-one-file.sh git-parse-remote.sh \
git-prune.sh git-pull.sh git-push.sh git-rebase.sh \
git-repack.sh git-request-pull.sh git-reset.sh \
- git-resolve.sh git-revert.sh git-sh-setup.sh \
+ git-resolve.sh git-revert.sh git-rm.sh git-sh-setup.sh \
git-tag.sh git-verify-tag.sh git-whatchanged.sh \
git-applymbox.sh git-applypatch.sh git-am.sh \
git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
diff -Nru git-1.2.2/git-rm.sh git-1.2.2.patched/git-rm.sh
--- git-1.2.2/git-rm.sh 1970-01-01 01:00:00.000000000 +0100
+++ git-1.2.2.patched/git-rm.sh 2006-02-21 23:35:11.000000000 +0100
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+USAGE='<file>...'
+SUBDIRECTORY_OK='Yes'
+. git-sh-setup
+
+show_only=
+verbose=
+remove_files=
+while : ; do
+ case "$1" in
+ -n)
+ show_only=true
+ ;;
+ -v)
+ verbose=--verbose
+ ;;
+ -f)
+ remove_files=true
+ ;;
+ --)
+ shift
+ break
+ ;;
+ -*)
+ usage
+ ;;
+ *)
+ break
+ ;;
+ esac
+ shift
+done
+
+# This is typo-proofing. If some paths match and some do not, we want
+# to do nothing.
+case "$#" in
+0) ;;
+*)
+ git-ls-files --error-unmatch -- "$@" >/dev/null || {
+ echo >&2 "Maybe you misspelled it?"
+ exit 1
+ }
+ ;;
+esac
+
+files=$(
+ if test -f "$GIT_DIR/info/exclude" ; then
+ git-ls-files \
+ --exclude-from="$GIT_DIR/info/exclude" \
+ --exclude-per-directory=.gitignore -- "$@"
+ else
+ git-ls-files \
+ --exclude-per-directory=.gitignore -- "$@"
+ fi | sort | uniq
+)
+
+case "$show_only" in
+true)
+ echo $files
+ ;;
+*)
+ [[ "$remove_files" = "true" ]] && rm -f -- $files
+ git-update-index --remove $verbose $files
+ ;;
+esac
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 191 bytes --]
^ permalink raw reply
* Re: [PATCH] fmt-merge-msg: avoid open "-|" list form for Perl 5.6
From: Eric Wong @ 2006-02-21 22:35 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Alex Riesen, Sam Vilain, Junio C Hamano, git
In-Reply-To: <Pine.LNX.4.63.0602212315400.12634@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> Hi,
>
> On Tue, 21 Feb 2006, Alex Riesen wrote:
>
> > Sam Vilain, Tue, Feb 21, 2006 21:36:50 +0100:
> > > >
> > > >>* Eric, thanks for the hint. I have this four-patch series.
> > > >> Could people with perl 5.6 please check them?
> > > >
> > > >
> > > >Does not work here (ActiveState Build 811, Perl 5.8.6):
> > > >
> > > >$ perl -e 'open(F, "-|")'
> > > >'-' is not recognized as an internal or external command,
> > > >operable program or batch file.
> > >
> > > Portability, Ease of Coding, Few CPAN Module Dependencies. Pick any two.
> > >
> >
> > Sometimes an upgrade is just out of question. Besides, that'd mean an
> > upgrade to another operating system, because very important scripts
> > over here a just not portable to anything else but
> > "ActiveState Perl on Windows (TM)"
> > I just have no choice.
>
> Maybe I am stating the obvious, but it seems that
>
> open (F, "git-blabla -option |");
>
> would be more portable.
>
> Alex, would this work on ActiveState?
>
> Perl gurus, is the latter way to open a pipe considered awful or what?
It's OK as long as all arguments are are shell-safe (quoted/escaped
properly). Shouldn't be a problem with constant strings at all.
> P.S.: Eric, we rely on fork() anyway. Most of git's programs just don't
> work without a fork().
Yes, apparently there's some fork() emulation in some *doze places and
not others.
--
Eric Wong
^ permalink raw reply
* Re: [PATCH] Add new git-rm command with documentation
From: Shawn Pearce @ 2006-02-21 22:32 UTC (permalink / raw)
To: Krzysiek Pawlik; +Cc: cworth, git
In-Reply-To: <43FB9455.6010402@people.pl>
Krzysiek Pawlik <krzysiek.pawlik@people.pl> wrote:
[...]
> +while : ; do
> + case "$1" in
> + -n)
> + show_only=true
> + ;;
> + -v)
> + verbose=--verbose
> + ;;
> + -f)
> + remove_files=true
> + ;;
> + --)
> + break
> + ;;
> + -*)
> + usage
> + ;;
> + *)
> + break
> + ;;
> + esac
> + shift
> +done
[...]
You are leaving -- in $@ for processing later, which means we'll
try to delete the file '--'. :-)
I think a shift before the break in the -- case would fix this.
--
Shawn.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox