Skip to content

Commit

Permalink
Merge branch 'master' into jc/combine
Browse files Browse the repository at this point in the history
* master:
  stripspace: make sure not to leave an incomplete line.
  git-commit: do not muck with commit message when no_edit is set.
  When showing a commit message, do not lose an incomplete line.
  Retire t5501-old-fetch-and-upload test.
  • Loading branch information
Junio C Hamano committed Apr 12, 2006
2 parents 8bc7574 + f4ee3eb commit 3103c00
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 58 deletions.
4 changes: 2 additions & 2 deletions commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,11 @@ static int get_one_line(const char *msg, unsigned long len)

while (len--) {
char c = *msg++;
if (!c)
break;
ret++;
if (c == '\n')
break;
if (!c)
return 0;
}
return ret;
}
Expand Down
17 changes: 12 additions & 5 deletions git-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ t)
;;
esac

if [ -f "$GIT_DIR/MERGE_HEAD" ]; then
if test -f "$GIT_DIR/MERGE_HEAD" && test -z "$no_edit"; then
echo "#"
echo "# It looks like you may be committing a MERGE."
echo "# If this is not correct, please remove the file"
Expand Down Expand Up @@ -605,16 +605,23 @@ else
current=
fi

{
test -z "$only_include_assumed" || echo "$only_include_assumed"
run_status
} >>"$GIT_DIR"/COMMIT_EDITMSG
if test -z "$no_edit"
then
{
test -z "$only_include_assumed" || echo "$only_include_assumed"
run_status
} >>"$GIT_DIR"/COMMIT_EDITMSG
else
# we need to check if there is anything to commit
run_status >/dev/null
fi
if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" -a -z "$amend" ]
then
rm -f "$GIT_DIR/COMMIT_EDITMSG"
run_status
exit 1
fi

case "$no_edit" in
'')
case "${VISUAL:-$EDITOR},$TERM" in
Expand Down
11 changes: 8 additions & 3 deletions stripspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* Remove empty lines from the beginning and end.
*
* Turn multiple consecutive empty lines into just one
* empty line.
* empty line. Return true if it is an incomplete line.
*/
static void cleanup(char *line)
static int cleanup(char *line)
{
int len = strlen(line);

Expand All @@ -21,16 +21,19 @@ static void cleanup(char *line)
len--;
line[len] = 0;
} while (len > 1);
return 0;
}
return 1;
}

int main(int argc, char **argv)
{
int empties = -1;
int incomplete = 0;
char line[1024];

while (fgets(line, sizeof(line), stdin)) {
cleanup(line);
incomplete = cleanup(line);

/* Not just an empty line? */
if (line[0] != '\n') {
Expand All @@ -44,5 +47,7 @@ int main(int argc, char **argv)
continue;
empties++;
}
if (incomplete)
putchar('\n');
return 0;
}
48 changes: 0 additions & 48 deletions t/t5501-old-fetch-and-upload.sh

This file was deleted.

0 comments on commit 3103c00

Please sign in to comment.