Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Documentation/RelNotes/2.52.0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ Performance, Internal Implementation, Development Support etc.
* Documentation for "git log --pretty" options has been updated
to make it easier to translate.

* Instead of three library archives (one for git, one for reftable,
and one for xdiff), roll everything into a single libgit.a archive.
This would help later effort to FFI into Rust.


Fixes since v2.51
-----------------
Expand Down Expand Up @@ -329,6 +333,19 @@ including security updates, are included in this release.
you would get from "git format-patch --notes=..." for a singleton
patch.

* The code in "git add -p" and friends to iterate over hunks was
riddled with bugs, which has been corrected.

* A few more things that patch authors can do to help maintainer to
keep track of their topics better.
(merge 1a41698841 tb/doc-submitting-patches later to maint).

* An earlier addition to "git diff --no-index A B" to limit the
output with pathspec after the two directories misbehaved when
these directories were given with a trailing slash, which has been
corrected.
(merge c0bec06cfe jk/diff-no-index-with-pathspec-fix later to maint).

* Other code cleanup, docfix, build fix, etc.
(merge 823d537fa7 kh/doc-git-log-markup-fix later to maint).
(merge cf7efa4f33 rj/t6137-cygwin-fix later to maint).
Expand Down
29 changes: 21 additions & 8 deletions Documentation/SubmittingPatches
Original file line number Diff line number Diff line change
Expand Up @@ -579,14 +579,27 @@ line via `git format-patch --notes`.
[[the-topic-summary]]
*This is EXPERIMENTAL*.

When sending a topic, you can propose a one-paragraph summary that
should appear in the "What's cooking" report when it is picked up to
explain the topic. If you choose to do so, please write a 2-5 line
paragraph that will fit well in our release notes (see many bulleted
entries in the Documentation/RelNotes/* files for examples), and make
it the first paragraph of the cover letter. For a single-patch
series, use the space between the three-dash line and the diffstat, as
described earlier.
When sending a topic, you can optionally propose a topic name and/or a
one-paragraph summary that should appear in the "What's cooking"
report when it is picked up to explain the topic. If you choose to do
so, please write a 2-5 line paragraph that will fit well in our
release notes (see many bulleted entries in the
Documentation/RelNotes/* files for examples), and make it the first
(or second, if including a suggested topic name) paragraph of the
cover letter. If suggesting a topic name, use the format
"XX/your-topic-name", where "XX" is a stand-in for the primary
author's initials, and "your-topic-name" is a brief, dash-delimited
description of what your topic does. For a single-patch series, use
the space between the three-dash line and the diffstat, as described
earlier.

[[multi-series-efforts]]
If your patch series is part of a larger effort spanning multiple
patch series, briefly describe the broader goal, and state where the
current series fits into that goal. If you are suggesting a topic
name as in <<the-topic-summary, section above>>, consider
"XX/the-broader-goal-part-one", "XX/the-broader-goal-part-two", and so
on.

[[attachment]]
Do not attach the patch as a MIME attachment, compressed or not.
Expand Down
8 changes: 4 additions & 4 deletions Documentation/git-add.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,10 @@ patch::
d - do not stage this hunk or any of the later hunks in the file
g - select a hunk to go to
/ - search for a hunk matching the given regex
j - leave this hunk undecided, see next undecided hunk
J - leave this hunk undecided, see next hunk
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
j - go to the next undecided hunk, roll over at the bottom
J - go to the next hunk, roll over at the bottom
k - go to the previous undecided hunk, roll over at the top
K - go to the previous hunk, roll over at the top
s - split the current hunk into smaller hunks
e - manually edit the current hunk
p - print the current hunk
Expand Down
64 changes: 24 additions & 40 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -927,16 +927,13 @@ export PYTHON_PATH
TEST_SHELL_PATH = $(SHELL_PATH)

LIB_FILE = libgit.a
XDIFF_LIB = xdiff/lib.a
REFTABLE_LIB = reftable/libreftable.a
ifdef DEBUG
RUST_LIB = target/debug/libgitcore.a
else
RUST_LIB = target/release/libgitcore.a
endif

# xdiff and reftable libs may in turn depend on what is in libgit.a
GITLIBS = common-main.o $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(LIB_FILE)
GITLIBS = common-main.o $(LIB_FILE)
EXTLIBS =

GIT_USER_AGENT = git/$(GIT_VERSION)
Expand Down Expand Up @@ -1248,6 +1245,20 @@ LIB_OBJS += refs/iterator.o
LIB_OBJS += refs/packed-backend.o
LIB_OBJS += refs/ref-cache.o
LIB_OBJS += refspec.o
LIB_OBJS += reftable/basics.o
LIB_OBJS += reftable/block.o
LIB_OBJS += reftable/blocksource.o
LIB_OBJS += reftable/error.o
LIB_OBJS += reftable/fsck.o
LIB_OBJS += reftable/iter.o
LIB_OBJS += reftable/merged.o
LIB_OBJS += reftable/pq.o
LIB_OBJS += reftable/record.o
LIB_OBJS += reftable/stack.o
LIB_OBJS += reftable/system.o
LIB_OBJS += reftable/table.o
LIB_OBJS += reftable/tree.o
LIB_OBJS += reftable/writer.o
LIB_OBJS += remote.o
LIB_OBJS += replace-object.o
LIB_OBJS += repo-settings.o
Expand Down Expand Up @@ -1322,6 +1333,13 @@ LIB_OBJS += write-or-die.o
LIB_OBJS += ws.o
LIB_OBJS += wt-status.o
LIB_OBJS += xdiff-interface.o
LIB_OBJS += xdiff/xdiffi.o
LIB_OBJS += xdiff/xemit.o
LIB_OBJS += xdiff/xhistogram.o
LIB_OBJS += xdiff/xmerge.o
LIB_OBJS += xdiff/xpatience.o
LIB_OBJS += xdiff/xprepare.o
LIB_OBJS += xdiff/xutils.o

BUILTIN_OBJS += builtin/add.o
BUILTIN_OBJS += builtin/am.o
Expand Down Expand Up @@ -2756,31 +2774,6 @@ reconfigure config.mak.autogen: config.status
.PHONY: reconfigure # This is a convenience target.
endif

XDIFF_OBJS += xdiff/xdiffi.o
XDIFF_OBJS += xdiff/xemit.o
XDIFF_OBJS += xdiff/xhistogram.o
XDIFF_OBJS += xdiff/xmerge.o
XDIFF_OBJS += xdiff/xpatience.o
XDIFF_OBJS += xdiff/xprepare.o
XDIFF_OBJS += xdiff/xutils.o
.PHONY: xdiff-objs
xdiff-objs: $(XDIFF_OBJS)

REFTABLE_OBJS += reftable/basics.o
REFTABLE_OBJS += reftable/block.o
REFTABLE_OBJS += reftable/blocksource.o
REFTABLE_OBJS += reftable/error.o
REFTABLE_OBJS += reftable/fsck.o
REFTABLE_OBJS += reftable/iter.o
REFTABLE_OBJS += reftable/merged.o
REFTABLE_OBJS += reftable/pq.o
REFTABLE_OBJS += reftable/record.o
REFTABLE_OBJS += reftable/stack.o
REFTABLE_OBJS += reftable/system.o
REFTABLE_OBJS += reftable/table.o
REFTABLE_OBJS += reftable/tree.o
REFTABLE_OBJS += reftable/writer.o

TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS)) $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))

.PHONY: test-objs
Expand All @@ -2801,9 +2794,8 @@ OBJECTS += $(GIT_OBJS)
OBJECTS += $(SCALAR_OBJS)
OBJECTS += $(PROGRAM_OBJS)
OBJECTS += $(TEST_OBJS)
OBJECTS += $(XDIFF_OBJS)
OBJECTS += $(FUZZ_OBJS)
OBJECTS += $(REFTABLE_OBJS) $(REFTABLE_TEST_OBJS)
OBJECTS += $(REFTABLE_TEST_OBJS)
OBJECTS += $(UNIT_TEST_OBJS)
OBJECTS += $(CLAR_TEST_OBJS)
OBJECTS += $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(UNIT_TEST_PROGRAMS))
Expand Down Expand Up @@ -2961,12 +2953,6 @@ $(RUST_LIB): Cargo.toml $(RUST_SOURCES)
.PHONY: rust
rust: $(RUST_LIB)

$(XDIFF_LIB): $(XDIFF_OBJS)
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^

$(REFTABLE_LIB): $(REFTABLE_OBJS)
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^

export DEFAULT_EDITOR DEFAULT_PAGER

Documentation/GIT-EXCLUDED-PROGRAMS: FORCE
Expand Down Expand Up @@ -3805,7 +3791,7 @@ clean: profile-clean coverage-clean cocciclean
$(RM) git.rc git.res
$(RM) $(OBJECTS)
$(RM) headless-git.o
$(RM) $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB)
$(RM) $(LIB_FILE)
$(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS)
$(RM) $(TEST_PROGRAMS)
$(RM) $(FUZZ_PROGRAMS)
Expand Down Expand Up @@ -3999,8 +3985,6 @@ endif

LIBGIT_PUB_OBJS += contrib/libgit-sys/public_symbol_export.o
LIBGIT_PUB_OBJS += libgit.a
LIBGIT_PUB_OBJS += reftable/libreftable.a
LIBGIT_PUB_OBJS += xdiff/lib.a

LIBGIT_PARTIAL_EXPORT = contrib/libgit-sys/partial_symbol_export.o

Expand Down
75 changes: 53 additions & 22 deletions add-patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1408,17 +1408,38 @@ static size_t display_hunks(struct add_p_state *s,
}

static const char help_patch_remainder[] =
N_("j - leave this hunk undecided, see next undecided hunk\n"
"J - leave this hunk undecided, see next hunk\n"
"k - leave this hunk undecided, see previous undecided hunk\n"
"K - leave this hunk undecided, see previous hunk\n"
N_("j - go to the next undecided hunk, roll over at the bottom\n"
"J - go to the next hunk, roll over at the bottom\n"
"k - go to the previous undecided hunk, roll over at the top\n"
"K - go to the previous hunk, roll over at the top\n"
"g - select a hunk to go to\n"
"/ - search for a hunk matching the given regex\n"
"s - split the current hunk into smaller hunks\n"
"e - manually edit the current hunk\n"
"p - print the current hunk, 'P' to use the pager\n"
"? - print help\n");

static size_t dec_mod(size_t a, size_t m)
{
return a > 0 ? a - 1 : m - 1;
}

static size_t inc_mod(size_t a, size_t m)
{
return a < m - 1 ? a + 1 : 0;
}

static bool get_first_undecided(const struct file_diff *file_diff, size_t *idx)
{
for (size_t i = 0; i < file_diff->hunk_nr; i++) {
if (file_diff->hunk[i].use == UNDECIDED_HUNK) {
*idx = i;
return true;
}
}
return false;
}

static int patch_update_file(struct add_p_state *s,
struct file_diff *file_diff)
{
Expand All @@ -1429,15 +1450,6 @@ static int patch_update_file(struct add_p_state *s,
struct child_process cp = CHILD_PROCESS_INIT;
int colored = !!s->colored.len, quit = 0, use_pager = 0;
enum prompt_mode_type prompt_mode_type;
enum {
ALLOW_GOTO_PREVIOUS_HUNK = 1 << 0,
ALLOW_GOTO_PREVIOUS_UNDECIDED_HUNK = 1 << 1,
ALLOW_GOTO_NEXT_HUNK = 1 << 2,
ALLOW_GOTO_NEXT_UNDECIDED_HUNK = 1 << 3,
ALLOW_SEARCH_AND_GOTO = 1 << 4,
ALLOW_SPLIT = 1 << 5,
ALLOW_EDIT = 1 << 6
} permitted = 0;

/* Empty added files have no hunks */
if (!file_diff->hunk_nr && !file_diff->added)
Expand All @@ -1447,6 +1459,16 @@ static int patch_update_file(struct add_p_state *s,
render_diff_header(s, file_diff, colored, &s->buf);
fputs(s->buf.buf, stdout);
for (;;) {
enum {
ALLOW_GOTO_PREVIOUS_HUNK = 1 << 0,
ALLOW_GOTO_PREVIOUS_UNDECIDED_HUNK = 1 << 1,
ALLOW_GOTO_NEXT_HUNK = 1 << 2,
ALLOW_GOTO_NEXT_UNDECIDED_HUNK = 1 << 3,
ALLOW_SEARCH_AND_GOTO = 1 << 4,
ALLOW_SPLIT = 1 << 5,
ALLOW_EDIT = 1 << 6
} permitted = 0;

if (hunk_index >= file_diff->hunk_nr)
hunk_index = 0;
hunk = file_diff->hunk_nr
Expand All @@ -1456,13 +1478,17 @@ static int patch_update_file(struct add_p_state *s,
undecided_next = -1;

if (file_diff->hunk_nr) {
for (i = hunk_index - 1; i >= 0; i--)
for (i = dec_mod(hunk_index, file_diff->hunk_nr);
i != hunk_index;
i = dec_mod(i, file_diff->hunk_nr))
if (file_diff->hunk[i].use == UNDECIDED_HUNK) {
undecided_previous = i;
break;
}

for (i = hunk_index + 1; i < file_diff->hunk_nr; i++)
for (i = inc_mod(hunk_index, file_diff->hunk_nr);
i != hunk_index;
i = inc_mod(i, file_diff->hunk_nr))
if (file_diff->hunk[i].use == UNDECIDED_HUNK) {
undecided_next = i;
break;
Expand Down Expand Up @@ -1496,15 +1522,15 @@ static int patch_update_file(struct add_p_state *s,
permitted |= ALLOW_GOTO_PREVIOUS_UNDECIDED_HUNK;
strbuf_addstr(&s->buf, ",k");
}
if (hunk_index) {
if (file_diff->hunk_nr > 1) {
permitted |= ALLOW_GOTO_PREVIOUS_HUNK;
strbuf_addstr(&s->buf, ",K");
}
if (undecided_next >= 0) {
permitted |= ALLOW_GOTO_NEXT_UNDECIDED_HUNK;
strbuf_addstr(&s->buf, ",j");
}
if (hunk_index + 1 < file_diff->hunk_nr) {
if (file_diff->hunk_nr > 1) {
permitted |= ALLOW_GOTO_NEXT_HUNK;
strbuf_addstr(&s->buf, ",J");
}
Expand Down Expand Up @@ -1569,6 +1595,8 @@ static int patch_update_file(struct add_p_state *s,
if (hunk->use == UNDECIDED_HUNK)
hunk->use = USE_HUNK;
}
if (!get_first_undecided(file_diff, &hunk_index))
hunk_index = 0;
} else if (hunk->use == UNDECIDED_HUNK) {
hunk->use = USE_HUNK;
}
Expand All @@ -1579,6 +1607,8 @@ static int patch_update_file(struct add_p_state *s,
if (hunk->use == UNDECIDED_HUNK)
hunk->use = SKIP_HUNK;
}
if (!get_first_undecided(file_diff, &hunk_index))
hunk_index = 0;
} else if (hunk->use == UNDECIDED_HUNK) {
hunk->use = SKIP_HUNK;
}
Expand All @@ -1588,24 +1618,25 @@ static int patch_update_file(struct add_p_state *s,
}
} else if (s->answer.buf[0] == 'K') {
if (permitted & ALLOW_GOTO_PREVIOUS_HUNK)
hunk_index--;
hunk_index = dec_mod(hunk_index,
file_diff->hunk_nr);
else
err(s, _("No previous hunk"));
err(s, _("No other hunk"));
} else if (s->answer.buf[0] == 'J') {
if (permitted & ALLOW_GOTO_NEXT_HUNK)
hunk_index++;
else
err(s, _("No next hunk"));
err(s, _("No other hunk"));
} else if (s->answer.buf[0] == 'k') {
if (permitted & ALLOW_GOTO_PREVIOUS_UNDECIDED_HUNK)
hunk_index = undecided_previous;
else
err(s, _("No previous hunk"));
err(s, _("No other undecided hunk"));
} else if (s->answer.buf[0] == 'j') {
if (permitted & ALLOW_GOTO_NEXT_UNDECIDED_HUNK)
hunk_index = undecided_next;
else
err(s, _("No next hunk"));
err(s, _("No other undecided hunk"));
} else if (s->answer.buf[0] == 'g') {
char *pend;
unsigned long response;
Expand Down
Loading