summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--csum-file.c18
-rw-r--r--csum-file.h1
-rwxr-xr-xgit-rebase--interactive.sh3
-rw-r--r--index-pack.c1
-rwxr-xr-xt/t3404-rebase-interactive.sh11
-rw-r--r--t/test-lib.sh3
6 files changed, 29 insertions, 8 deletions
diff --git a/csum-file.c b/csum-file.c
index 717d29fc03..2ddb12a0b7 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, void *buf, unsigned int count)
+static void flush(struct sha1file *f, void * buf, unsigned int count)
{
for (;;) {
int ret = xwrite(f->fd, buf, count);
@@ -30,22 +30,28 @@ static void sha1flush(struct sha1file *f, void *buf, 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) {
git_SHA1_Update(&f->ctx, f->buffer, offset);
- sha1flush(f, f->buffer, offset);
+ flush(f, f->buffer, offset);
f->offset = 0;
}
+}
+
+int sha1close(struct sha1file *f, unsigned char *result, unsigned int flags)
+{
+ int fd;
+
+ sha1flush(f);
git_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, f->buffer, 20);
+ flush(f, f->buffer, 20);
if (flags & CSUM_FSYNC)
fsync_or_die(f->fd, f->name);
if (close(f->fd))
@@ -83,7 +89,7 @@ int sha1write(struct sha1file *f, void *buf, unsigned int count)
left -= nr;
if (!left) {
git_SHA1_Update(&f->ctx, data, offset);
- sha1flush(f, data, offset);
+ flush(f, data, offset);
offset = 0;
}
f->offset = offset;
diff --git a/csum-file.h b/csum-file.h
index 9e13342eb3..294add2a91 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/git-rebase--interactive.sh b/git-rebase--interactive.sh
index bdec43c3f6..124cb5846b 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/index-pack.c b/index-pack.c
index 73860bf3da..d3a4d31b4e 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;
}
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index e0ded197ec..7d10a27f1d 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 <somebody@else.com>"
+ test $(git rev-parse branch3) != $(git rev-parse branch4) &&
+ git rebase -i branch3 &&
+ test $(git rev-parse branch3) = $(git rev-parse branch4)
+
+'
+
test_done
diff --git a/t/test-lib.sh b/t/test-lib.sh
index e2b106cb6a..fb89741125 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