From 838cd34664422863096f1a089f779bed1f00edf6 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Thu, 9 Oct 2008 22:08:51 -0400 Subject: fix pread()'s short read in index-pack Since v1.6.0.2~13^2~ the completion of a thin pack uses sha1write() for its ability to compute a SHA1 on the written data. This also provides data buffering which, along with commit 92392b4a45, will confuse pread() whenever an appended object is 1) freed due to memory pressure because of the depth-first delta processing, and 2) needed again because it has many delta children, and 3) its data is still buffered by sha1write(). Let's fix the issue by simply forcing cached data out when such an object is written so it can be pread()'d at leisure. Signed-off-by: Nicolas Pitre Signed-off-by: Shawn O. Pearce diff --git a/csum-file.c b/csum-file.c index 2838954..cfc1ac4 100644 --- a/csum-file.c +++ b/csum-file.c @@ -11,7 +11,7 @@ #include "progress.h" #include "csum-file.h" -static void sha1flush(struct sha1file *f, unsigned int count) +static void flush(struct sha1file *f, unsigned int count) { void *buf = f->buffer; @@ -32,22 +32,28 @@ static void sha1flush(struct sha1file *f, unsigned int count) } } -int sha1close(struct sha1file *f, unsigned char *result, unsigned int flags) +void sha1flush(struct sha1file *f) { - int fd; unsigned offset = f->offset; if (offset) { SHA1_Update(&f->ctx, f->buffer, offset); - sha1flush(f, offset); + flush(f, offset); f->offset = 0; } +} + +int sha1close(struct sha1file *f, unsigned char *result, unsigned int flags) +{ + int fd; + + sha1flush(f); SHA1_Final(f->buffer, &f->ctx); if (result) hashcpy(result, f->buffer); if (flags & (CSUM_CLOSE | CSUM_FSYNC)) { /* write checksum and close fd */ - sha1flush(f, 20); + flush(f, 20); if (flags & CSUM_FSYNC) fsync_or_die(f->fd, f->name); if (close(f->fd)) @@ -76,7 +82,7 @@ int sha1write(struct sha1file *f, void *buf, unsigned int count) left -= nr; if (!left) { SHA1_Update(&f->ctx, f->buffer, offset); - sha1flush(f, offset); + flush(f, offset); offset = 0; } f->offset = offset; diff --git a/csum-file.h b/csum-file.h index 72c9487..01f13b5 100644 --- a/csum-file.h +++ b/csum-file.h @@ -24,6 +24,7 @@ extern struct sha1file *sha1fd(int fd, const char *name); extern struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp); extern int sha1close(struct sha1file *, unsigned char *, unsigned int); extern int sha1write(struct sha1file *, void *, unsigned int); +extern void sha1flush(struct sha1file *f); extern void crc32_begin(struct sha1file *); extern uint32_t crc32_end(struct sha1file *); diff --git a/index-pack.c b/index-pack.c index c45ae20..2a36620 100644 --- a/index-pack.c +++ b/index-pack.c @@ -707,6 +707,7 @@ static struct object_entry *append_obj_to_pack(struct sha1file *f, obj[1].idx.offset = obj[0].idx.offset + n; obj[1].idx.offset += write_compressed(f, buf, size); obj[0].idx.crc32 = crc32_end(f); + sha1flush(f); hashcpy(obj->idx.sha1, sha1); return obj; } -- cgit v0.10.2-6-g49f6 From b8eecafd888d219633f4c29e8b6a90fc21a46dfd Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 10 Oct 2008 00:07:10 +0200 Subject: test-lib: fix color reset in say_color() When executing a single test with colors enabled, the cursor was not set back to the previous one, and you had to hit an extra enter to get it back. Work around this problem by calling 'tput sgr0' before printing the final newline. Signed-off-by: Miklos Vajna Signed-off-by: Shawn O. Pearce diff --git a/t/test-lib.sh b/t/test-lib.sh index 11c0275..3569836 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -112,8 +112,9 @@ if test -n "$color"; then *) test -n "$quiet" && return;; esac shift - echo "* $*" + printf "* $*" tput sgr0 + echo ) } else -- cgit v0.10.2-6-g49f6 From ff74126c03a8dfd04e7533573a5c420f2a7112ac Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 10 Oct 2008 13:42:12 +0200 Subject: rebase -i: do not fail when there is no commit to cherry-pick In case there is no commit to apply (for example because you rebase to upstream and all your local patches have been applied there), do not fail. The non-interactive rebase already behaves that way. Do this by introducing a new command, "noop", which is substituted for an empty commit list, so that deleting the commit list can still abort as before. Signed-off-by: Johannes Schindelin Signed-off-by: Shawn O. Pearce diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index bdec43c..124cb58 100755 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -277,7 +277,7 @@ do_next () { "$DOTEST"/amend || exit read command sha1 rest < "$TODO" case "$command" in - '#'*|'') + '#'*|''|noop) mark_action_done ;; pick|p) @@ -584,6 +584,7 @@ first and then run 'git rebase --continue' again." --abbrev=7 --reverse --left-right --cherry-pick \ $UPSTREAM...$HEAD | \ sed -n "s/^>/pick /p" > "$TODO" + test -s "$TODO" || echo noop >> "$TODO" cat >> "$TODO" << EOF # Rebase $SHORTUPSTREAM..$SHORTHEAD onto $SHORTONTO diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index e0ded19..7d10a27 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -419,4 +419,15 @@ test_expect_success 'rebase with a file named HEAD in worktree' ' ' +test_expect_success 'do "noop" when there is nothing to cherry-pick' ' + + git checkout -b branch4 HEAD && + GIT_EDITOR=: git commit --amend \ + --author="Somebody else " + test $(git rev-parse branch3) != $(git rev-parse branch4) && + git rebase -i branch3 && + test $(git rev-parse branch3) = $(git rev-parse branch4) + +' + test_done -- cgit v0.10.2-6-g49f6