bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bash patches format


From: Marty E. Plummer
Subject: Bash patches format
Date: Sat, 19 May 2018 08:46:02 -0500

Greetings,

In doing some research into ways to better improve the gentoo ebuild qa,
I ran across the fact that the official bash patches are provided as
-p0, context diffs.

I was hoping I could convince you to convert to -p1, unified diffs, such
as are produced by diff -u or git format-patch, for the following
reasons.

1. <opinion> unified diffs are easier to size up at a glance as compared
to an equivalent context diff; the two following snippets cover the same
data/changes, but the unified diff is easier to read at a glance:

*** a/lib/readline/history.c    2015-12-28 13:50:31.000000000 -0500
--- b/lib/readline/history.c    2016-09-30 14:28:40.000000000 -0400
***************
*** 308,312 ****
        {
          if (history_stifled && history_max_entries > 0)
!           history_size = history_max_entries + 2;
          else
            history_size = DEFAULT_HISTORY_INITIAL_SIZE;
--- 310,316 ----
        {
          if (history_stifled && history_max_entries > 0)
!           history_size = (history_max_entries > MAX_HISTORY_INITIAL_SIZE)
!                               ? MAX_HISTORY_INITIAL_SIZE
!                               : history_max_entries + 2;
          else
            history_size = DEFAULT_HISTORY_INITIAL_SIZE;

--- a/lib/readline/history.c    2015-12-28 13:50:31.000000000 -0500
+++ b/lib/readline/history.c    2016-09-30 14:28:40.000000000 -0400
@@ -308,5 +310,7 @@
        {
          if (history_stifled && history_max_entries > 0)
-           history_size = history_max_entries + 2;
+           history_size = (history_max_entries > MAX_HISTORY_INITIAL_SIZE)
+                               ? MAX_HISTORY_INITIAL_SIZE
+                               : history_max_entries + 2;
          else
            history_size = DEFAULT_HISTORY_INITIAL_SIZE;

2. unified diffs are, generally speaking, smaller than an equivalent
context diff, as in hunks where lines are added and removed or changed
(instead of just adding or removing lines), the hunk is copied twice in
a context diff. Depending on the general composition of a patch, an
equivalent unified diff is about 1/3 smaller than the same context diff.

3. A lot of downstream consumers are already taking these patches and
converting them to -p1 unified diffs in their source repos already, or,
barring that, have to make explicit exceptions to the 'norm' for their
packaging/buildscripts. For instance, fedora[1] and debian[2] 'mirror'
the official patchset, after converting them to -p1 unified, and gentoo
has to make an exception[3] to their eapply call in src_prepare() to
apply -p0 patches.

The above being said, I don't believe in asking for something to be done
without making an attempt of it yourself if it is within your ability.
As such, I have taken it upon myself to do the conversion for bash44-{001..019},
and am more than willing to do the same for any other existing patches,
if you're willing to continue to provide official patches in this
format, for the sake of reduction of duplicated work across all distros.
You can find them in my bash-patches[4] github repository.

Regards,
Marty.

[1]: https://src.fedoraproject.org/rpms/bash/tree/master
[2]: https://sources.debian.org/patches/bash/
[3]: 
https://github.com/gentoo/gentoo/blob/master/app-shells/bash/bash-4.4_p19.ebuild#L85-L87
Note the second patch, which is -p1, does not require extra args to
eapply
[4]: https://github.com/hanetzer/bash-patches



reply via email to

[Prev in Thread] Current Thread [Next in Thread]