How to find which release a changeset is in - linux

What's a way to find a release that a given changeset is in?
For example given this changeset:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commit;h=50d3e6399a61fca53c5c440a79f71299db66b803
How do I use git to tell me the earliest release this changeset made it into?

You can use git describe --contains $SHA1, which will give you the oldest tag that your commit is reachable from.

Related

Can't make a pull request

I have this repository that i forked from another one, and now i need to make a pull request to it, but it says that: "There isn’t anything to compare.", and my commits are not showing:
https://github.com/amorimll/desafio-sharenergy-2023-01
Any help is appreciated, really need this for today.
This is showing in the git rebase:
Short answer
will be checkout to your main branch get the lastest code, then go back to your current working on branch and do git rebase [currentBranchName] main
Explain
so when your create a branch from another branch, is like your created a snapshot code from that branch at that moment. ideally the branch you copied form should prevent make any more changes if possible, until you done working in the new branch and create the PR and done marge it.
what rebase command will do is in case the origin branch had changes, it will pull the latest code form that branch into your working branch first, then to applied any changes you was made for your current working branch. Usually this process will need have some conflict need to fix, if they changed the same file.
Hope this is help you understand :)

How to concat commit messages with GitLab MR squash?

I am using GitLab MR to push commits to my project.
I have a certain template in my commit message that I want to keep on my target branch (e.g. master).
for example:
[Notes]:
when pushing several commits in a single MR we get something like this:
Commit 1: [Notes]: Note1
Commit 2: Merge commit (the one I want to get rid of when squashing)
Commit 3: [Notes]: Note2
when squashing with GitLab MR the squashed commit message is the title of the MR, which prevents me to keep my original commits template.
Is there an option in GitLab setting to change the squashed message to be a concat of all commit messages? similar to interactive rebase in git.
wanted behavior:
Squashed Commit: [Notes]: Note1
Merge commit (the one I want to get rid of when squashing)
[Notes]: Note2
GitLab 14.9.2-ee
I managed to find what I was looking for, it is a GitLab feature introduced in the FREE edition since GitLab 14.6.
Open GitLab website -> Settings -> General -> Merge requests -> Squash commit message template.
Then in the textbox add the following flag:
%{all_commits}
The commit messages are shown in the squash message according to their chronological order.
I do have this checkbox (see attached image) in my merge request enabling me to change the Merge Commit Message but I am using: 15.2.1-ee I'm not sure on what version this got introduced. I think there was a similar functionality in previous versions.

View Git history before a specific commit ID in the current branch

I'd like some Git log command to list out the commits before some specific commit ID/hash in the current working branch.
E.g. Something like
git log --before <commit id>
But I haven't been able to find what the correct command to do this is.
Just give the commit hash as the ref to explore via log
git log <commitHash>
and it will output all history from that point, backwards, until initial commit.
Alternatively, if you need to exclude this specific commit itself, then refer to its parent with
git log <commitHash>^
Sidenote about your mention of "in the current working branch"
Branches are technically irrelevant here to tree traversal logic. This won't limit output to what's "in" the branch, largely because the common metaphor is quite bad : commits are just not "on" branches. Branches are to be seen as soft (and disposable) shortcuts to designate one commit in the tree.

GitVersion source only from branch name

By default GitVersion can increment version based on tags, branch names, commit messages, etc.
This is not convenient for my case because different people can increment version by mistake.
I'd like only branch name to be the source for GitVersion.
In GitVersion docs I've found only ignoring commit messages by adding "commit-message-incrementing: Disabled" line to GitVersion.yml
Any ideas how tags can be ignored?
I doubt you can. Tag is at the core of GitVersion. Check the "How it works" here:
https://gitversion.readthedocs.io/en/latest/more-info/how-it-works/

Target specific commit in gitolite rules

I need to forbid pushing of specific commit (by its sha). Is it possible to do with gitolite configuration?
I tried specifying something like
repo myRepo
- 794b62a8b1cf4417c8320a261177b43bd5d8331e = #all
But it does not work as intended. I guess that VREFs can help here but I din't find much info on that.
You can set in place a VREF which will list commits pushed and reject the push if one of those commits matches the one you want to block.
Check as an example src/VREF/MERGE-CHECK, which does use git rev-list to list commits.
See Adding a VREF to implement and add your own.

Resources