Skip to content

Commit e782e12

Browse files
committed
Merge branch 'maint'
* maint: rebase -i: do not fail when there is no commit to cherry-pick test-lib: fix color reset in say_color() fix pread()'s short read in index-pack Conflicts: csum-file.c
2 parents 23abd3f + ff74126 commit e782e12

File tree

6 files changed

+29
-8
lines changed

6 files changed

+29
-8
lines changed

csum-file.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "progress.h"
1212
#include "csum-file.h"
1313

14-
static void sha1flush(struct sha1file *f, void *buf, unsigned int count)
14+
static void flush(struct sha1file *f, void * buf, unsigned int count)
1515
{
1616
for (;;) {
1717
int ret = xwrite(f->fd, buf, count);
@@ -30,22 +30,28 @@ static void sha1flush(struct sha1file *f, void *buf, unsigned int count)
3030
}
3131
}
3232

33-
int sha1close(struct sha1file *f, unsigned char *result, unsigned int flags)
33+
void sha1flush(struct sha1file *f)
3434
{
35-
int fd;
3635
unsigned offset = f->offset;
3736

3837
if (offset) {
3938
git_SHA1_Update(&f->ctx, f->buffer, offset);
40-
sha1flush(f, f->buffer, offset);
39+
flush(f, f->buffer, offset);
4140
f->offset = 0;
4241
}
42+
}
43+
44+
int sha1close(struct sha1file *f, unsigned char *result, unsigned int flags)
45+
{
46+
int fd;
47+
48+
sha1flush(f);
4349
git_SHA1_Final(f->buffer, &f->ctx);
4450
if (result)
4551
hashcpy(result, f->buffer);
4652
if (flags & (CSUM_CLOSE | CSUM_FSYNC)) {
4753
/* write checksum and close fd */
48-
sha1flush(f, f->buffer, 20);
54+
flush(f, f->buffer, 20);
4955
if (flags & CSUM_FSYNC)
5056
fsync_or_die(f->fd, f->name);
5157
if (close(f->fd))
@@ -83,7 +89,7 @@ int sha1write(struct sha1file *f, void *buf, unsigned int count)
8389
left -= nr;
8490
if (!left) {
8591
git_SHA1_Update(&f->ctx, data, offset);
86-
sha1flush(f, data, offset);
92+
flush(f, data, offset);
8793
offset = 0;
8894
}
8995
f->offset = offset;

csum-file.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ extern struct sha1file *sha1fd(int fd, const char *name);
2424
extern struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp);
2525
extern int sha1close(struct sha1file *, unsigned char *, unsigned int);
2626
extern int sha1write(struct sha1file *, void *, unsigned int);
27+
extern void sha1flush(struct sha1file *f);
2728
extern void crc32_begin(struct sha1file *);
2829
extern uint32_t crc32_end(struct sha1file *);
2930

git-rebase--interactive.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ do_next () {
277277
"$DOTEST"/amend || exit
278278
read command sha1 rest < "$TODO"
279279
case "$command" in
280-
'#'*|'')
280+
'#'*|''|noop)
281281
mark_action_done
282282
;;
283283
pick|p)
@@ -584,6 +584,7 @@ first and then run 'git rebase --continue' again."
584584
--abbrev=7 --reverse --left-right --cherry-pick \
585585
$UPSTREAM...$HEAD | \
586586
sed -n "s/^>/pick /p" > "$TODO"
587+
test -s "$TODO" || echo noop >> "$TODO"
587588
cat >> "$TODO" << EOF
588589
589590
# Rebase $SHORTUPSTREAM..$SHORTHEAD onto $SHORTONTO

index-pack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ static struct object_entry *append_obj_to_pack(struct sha1file *f,
707707
obj[1].idx.offset = obj[0].idx.offset + n;
708708
obj[1].idx.offset += write_compressed(f, buf, size);
709709
obj[0].idx.crc32 = crc32_end(f);
710+
sha1flush(f);
710711
hashcpy(obj->idx.sha1, sha1);
711712
return obj;
712713
}

t/t3404-rebase-interactive.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,4 +419,15 @@ test_expect_success 'rebase with a file named HEAD in worktree' '
419419
420420
'
421421

422+
test_expect_success 'do "noop" when there is nothing to cherry-pick' '
423+
424+
git checkout -b branch4 HEAD &&
425+
GIT_EDITOR=: git commit --amend \
426+
--author="Somebody else <[email protected]>"
427+
test $(git rev-parse branch3) != $(git rev-parse branch4) &&
428+
git rebase -i branch3 &&
429+
test $(git rev-parse branch3) = $(git rev-parse branch4)
430+
431+
'
432+
422433
test_done

t/test-lib.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ if test -n "$color"; then
112112
*) test -n "$quiet" && return;;
113113
esac
114114
shift
115-
echo "* $*"
115+
printf "* $*"
116116
tput sgr0
117+
echo
117118
)
118119
}
119120
else

0 commit comments

Comments
 (0)