git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/3] cleanup for 'dl/range-diff-with-notes'
@ 2019-12-06 20:16 Denton Liu
  2019-12-06 20:16 ` [PATCH 1/3] t3206: fix incorrect test name Denton Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Denton Liu @ 2019-12-06 20:16 UTC (permalink / raw)
  To: Git Mailing List

This series performs some small polishing touches for the
'dl/range-diff-with-notes' topic. Notably, we fix an incorrect test case
name but we also perform some nit-picky cleanup for the range-diff code.

Denton Liu (3):
  t3206: fix incorrect test name
  range-diff: mark pointers as const
  range-diff: clear `other_arg` at end of function

 builtin/range-diff.c  | 1 +
 range-diff.c          | 6 +++---
 range-diff.h          | 4 ++--
 t/t3206-range-diff.sh | 2 +-
 4 files changed, 7 insertions(+), 6 deletions(-)

-- 
2.24.0.612.g9b7bad38f5


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] t3206: fix incorrect test name
  2019-12-06 20:16 [PATCH 0/3] cleanup for 'dl/range-diff-with-notes' Denton Liu
@ 2019-12-06 20:16 ` Denton Liu
  2019-12-06 20:16 ` [PATCH 2/3] range-diff: mark pointers as const Denton Liu
  2019-12-06 20:16 ` [PATCH 3/3] range-diff: clear `other_arg` at end of function Denton Liu
  2 siblings, 0 replies; 4+ messages in thread
From: Denton Liu @ 2019-12-06 20:16 UTC (permalink / raw)
  To: Git Mailing List

The name of the test used to indicate that it was testing the `--notes`
option but it was really testing the `format.notes` configuration.
Correct the test name to reflect this.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 t/t3206-range-diff.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh
index ec2b456dbb..0575dd72b1 100755
--- a/t/t3206-range-diff.sh
+++ b/t/t3206-range-diff.sh
@@ -638,7 +638,7 @@ test_expect_success 'format-patch --range-diff with --notes' '
 	test_cmp expect actual
 '
 
-test_expect_success 'format-patch --range-diff with --notes' '
+test_expect_success 'format-patch --range-diff with format.notes config' '
 	git notes add -m "topic note" topic &&
 	git notes add -m "unmodified note" unmodified &&
 	test_when_finished git notes remove topic unmodified &&
-- 
2.24.0.612.g9b7bad38f5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] range-diff: mark pointers as const
  2019-12-06 20:16 [PATCH 0/3] cleanup for 'dl/range-diff-with-notes' Denton Liu
  2019-12-06 20:16 ` [PATCH 1/3] t3206: fix incorrect test name Denton Liu
@ 2019-12-06 20:16 ` Denton Liu
  2019-12-06 20:16 ` [PATCH 3/3] range-diff: clear `other_arg` at end of function Denton Liu
  2 siblings, 0 replies; 4+ messages in thread
From: Denton Liu @ 2019-12-06 20:16 UTC (permalink / raw)
  To: Git Mailing List

The contents pointed to by `diffopt` and `other_arg` should not be
modified. Mark these as `const` to indicate this.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 range-diff.c | 6 +++---
 range-diff.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/range-diff.c b/range-diff.c
index f56b4012a2..f745567cf6 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -41,7 +41,7 @@ static size_t find_end_of_line(char *buffer, unsigned long size)
  * as struct object_id (will need to be free()d).
  */
 static int read_patches(const char *range, struct string_list *list,
-			struct argv_array *other_arg)
+			const struct argv_array *other_arg)
 {
 	struct child_process cp = CHILD_PROCESS_INIT;
 	struct strbuf buf = STRBUF_INIT, contents = STRBUF_INIT;
@@ -506,8 +506,8 @@ static struct strbuf *output_prefix_cb(struct diff_options *opt, void *data)
 
 int show_range_diff(const char *range1, const char *range2,
 		    int creation_factor, int dual_color,
-		    struct diff_options *diffopt,
-		    struct argv_array *other_arg)
+		    const struct diff_options *diffopt,
+		    const struct argv_array *other_arg)
 {
 	int res = 0;
 
diff --git a/range-diff.h b/range-diff.h
index 7d918ab9ed..381d52f4d3 100644
--- a/range-diff.h
+++ b/range-diff.h
@@ -13,7 +13,7 @@
  */
 int show_range_diff(const char *range1, const char *range2,
 		    int creation_factor, int dual_color,
-		    struct diff_options *diffopt,
-		    struct argv_array *other_arg);
+		    const struct diff_options *diffopt,
+		    const struct argv_array *other_arg);
 
 #endif
-- 
2.24.0.612.g9b7bad38f5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] range-diff: clear `other_arg` at end of function
  2019-12-06 20:16 [PATCH 0/3] cleanup for 'dl/range-diff-with-notes' Denton Liu
  2019-12-06 20:16 ` [PATCH 1/3] t3206: fix incorrect test name Denton Liu
  2019-12-06 20:16 ` [PATCH 2/3] range-diff: mark pointers as const Denton Liu
@ 2019-12-06 20:16 ` Denton Liu
  2 siblings, 0 replies; 4+ messages in thread
From: Denton Liu @ 2019-12-06 20:16 UTC (permalink / raw)
  To: Git Mailing List

We were leaking memory by not clearing `other_arg` after we were done
using it. Clear it after we've finished using it.

Note that this isn't strictly necessary since the memory will be
reclaimed once the command exits. However, since we are releasing the
strbufs, we should also clear `other_arg` for consistency.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 builtin/range-diff.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/builtin/range-diff.c b/builtin/range-diff.c
index 98acf3533e..d8a4670629 100644
--- a/builtin/range-diff.c
+++ b/builtin/range-diff.c
@@ -84,6 +84,7 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
 	res = show_range_diff(range1.buf, range2.buf, creation_factor,
 			      simple_color < 1, &diffopt, &other_arg);
 
+	argv_array_clear(&other_arg);
 	strbuf_release(&range1);
 	strbuf_release(&range2);
 
-- 
2.24.0.612.g9b7bad38f5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-12-06 20:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-06 20:16 [PATCH 0/3] cleanup for 'dl/range-diff-with-notes' Denton Liu
2019-12-06 20:16 ` [PATCH 1/3] t3206: fix incorrect test name Denton Liu
2019-12-06 20:16 ` [PATCH 2/3] range-diff: mark pointers as const Denton Liu
2019-12-06 20:16 ` [PATCH 3/3] range-diff: clear `other_arg` at end of function Denton Liu

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).